Changeset 13803 for main/waeup.ikoba/trunk
- Timestamp:
- 6 Apr 2016, 05:04:26 (9 years ago)
- Location:
- main/waeup.ikoba/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/CHANGES.txt
r13802 r13803 4 4 0.2.dev0 (unreleased) 5 5 ===================== 6 7 * Enable temporary suspension of officer accounts. Plugins must be 8 updated after restart. 6 9 7 10 * Do only allow one running export job. -
main/waeup.ikoba/trunk/src/waeup/ikoba/authentication.py
r13801 r13803 210 210 self.phone = phone 211 211 self.public_name = public_name 212 self.suspended = False 212 213 self.setPassword(password) 213 214 self.setSiteRolesForPrincipal(roles) … … 226 227 if not self.password: 227 228 # unset/empty passwords do never match 229 return False 230 if self.suspended == True: 228 231 return False 229 232 passwordmanager = getUtility(IPasswordManager, 'SSHA') -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py
r13802 r13803 336 336 type='warning') 337 337 return 338 # Display appropriate flash message if credentials are correct 339 # but officer has been deactivated. 340 login = self.request.form['form.login'] 341 if login in grok.getSite()['users']: 342 user = grok.getSite()['users'][login] 343 password = self.request.form['form.password'] 344 passwordmanager = getUtility(IPasswordManager, 'SSHA') 345 if user.password is not None and \ 346 passwordmanager.checkPassword(user.password, password): 347 self.flash(_('Your user name and password are correct ' 348 'but yor account has been temporarily ' 349 'deactivated.'), 350 type='warning') 351 return 338 352 self.flash(_('You entered invalid credentials.'), type='danger') 339 353 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/templates/usereditformpage.pt
r11949 r13803 1 <p class="alert alert-danger" i18n:domain="waeup.kofa" 2 i18n:translate="officer_suspended_warning" 3 tal:condition="python: getattr(context, 'suspended', False)"> 4 <strong>ATTENTION:</strong> 5 This account has been suspended. The officer can't login. 6 </p> 7 1 8 <form action="." tal:attributes="action request/URL" method="post" 2 9 i18n:domain="waeup.ikoba" enctype="multipart/form-data" -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/templates/userscontainerpage.pt
r11949 r13803 12 12 <tr tal:repeat="account context/values"> 13 13 <td tal:content="account/name">USERNAME</td> 14 <td tal:content="account/title">TITLE</td> 14 <td> 15 <span tal:content="account/title">TITLE</span> 16 <span style="color:red" tal:condition="account/suspended">(suspended)</span> 17 </td> 15 18 <td nowrap tal:content="structure python:view.getSiteRoles(account)">SITE ROLES</td> 16 19 <td tal:content="structure python:view.getLocalRoles(account)">LOCAL ROLES</td> -
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/tests/test_browser.py
r13802 r13803 30 30 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase 31 31 from waeup.ikoba.app import Company 32 from waeup.ikoba.interfaces import IJobManager 32 from waeup.ikoba.interfaces import IJobManager, IUserAccount 33 33 from waeup.ikoba.tests.test_async import FunctionalAsyncTestCase 34 34 … … 160 160 return 161 161 162 163 class SupplementaryBrowserTests(CompanySetup): 164 # These are additional tests to browser.txt 165 166 def test_suspended_officer(self): 167 self.app['users'].addUser( 168 'officer', 'secret', title='Bob Officer', email='aa@aa.ng') 169 # Officer can't login if their password is not set 170 self.app['users']['officer'].password = None 171 self.browser.open('http://localhost/app/login') 172 self.browser.getControl(name="form.login").value = 'officer' 173 self.browser.getControl(name="form.password").value = 'secret' 174 self.browser.getControl("Login").click() 175 self.assertTrue( 176 'You entered invalid credentials.' in self.browser.contents) 177 # We set the password again 178 IUserAccount( 179 self.app['users']['officer']).setPassword('secret') 180 # Officers can't login if their account is suspended/deactivated 181 self.app['users']['officer'].suspended = True 182 self.browser.open('http://localhost/app/login') 183 self.browser.getControl(name="form.login").value = 'officer' 184 self.browser.getControl(name="form.password").value = 'secret' 185 self.browser.getControl("Login").click() 186 self.assertMatches( 187 '...but yor account has been temporarily deactivated...', 188 self.browser.contents) 189 self.assertFalse("Bob Officer" in self.browser.contents) 190 self.app['users']['officer'].suspended = False 191 self.browser.open('http://localhost/app/login') 192 self.browser.getControl(name="form.login").value = 'officer' 193 self.browser.getControl(name="form.password").value = 'secret' 194 self.browser.getControl("Login").click() 195 self.assertMatches( 196 '...You logged in...', self.browser.contents) 197 self.assertTrue("Bob Officer" in self.browser.contents) 198 self.browser.getLink("Logout").click() 199 # Suspended accounts are marked 200 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 201 self.browser.open('http://localhost/app/users') 202 self.assertFalse('(suspended)' in self.browser.contents) 203 self.app['users']['officer'].suspended = True 204 self.browser.open('http://localhost/app/users') 205 self.assertTrue( 206 '<span style="color:red">(suspended)</span>' 207 in self.browser.contents) 208 self.browser.open('http://localhost/app/users/officer') 209 self.assertTrue( 210 'This account has been suspended.' in self.browser.contents) 211 self.app['users']['officer'].suspended = False 212 self.browser.open('http://localhost/app/users/officer') 213 self.assertFalse( 214 'This account has been suspended.' in self.browser.contents) 215 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/authentication.py
r12809 r13803 73 73 return self.title 74 74 75 def suspended(self): 76 return self.context.suspended 77 75 78 @property 76 79 def failed_logins(self): -
main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py
r13802 r13803 482 482 """ 483 483 484 failed_logins = Attribute( """FailedLoginInfo for this account""")484 failed_logins = Attribute('FailedLoginInfo for this account') 485 485 486 486 name = schema.TextLine( 487 487 title = _(u'User Id'), 488 description = u'Login name of user',488 description = _(u'Login name of user'), 489 489 required = True,) 490 490 … … 495 495 public_name = schema.TextLine( 496 496 title = _(u'Public Name'), 497 description = u"Substitute for officer's real name "498 "in object histories.",497 description = _(u"Substitute for officer's real name " 498 "in student object histories."), 499 499 required = False,) 500 500 … … 522 522 ) 523 523 524 suspended = schema.Bool( 525 title = _(u'Account suspended'), 526 description = _(u'If set, the account is immediately blocked.'), 527 default = False, 528 required = False, 529 ) 524 530 525 531
Note: See TracChangeset for help on using the changeset viewer.