Changeset 6713
- Timestamp:
- 10 Sep 2011, 10:36:11 (13 years ago)
- Location:
- main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/authentication.py
r6680 r6713 26 26 from zope.component import getUtility 27 27 from zope.password.interfaces import IPasswordManager 28 from zope.pluggableauth.interfaces import IAuthenticatorPlugin 28 from zope.pluggableauth.interfaces import ( 29 IAuthenticatorPlugin, ICredentialsPlugin) 30 from zope.pluggableauth.plugins.session import SessionCredentialsPlugin 29 31 from waeup.sirp.authentication import PrincipalInfo, get_principal_role_manager 30 32 from waeup.sirp.interfaces import IAuthPluginUtility, IUserAccount … … 117 119 return None 118 120 if not account.checkPassword(credentials['password']): 119 return None 121 # XXX: This is not a proper solution. Works, however, basically 122 if credentials.get('reset', False) is not True: 123 return None 120 124 return PrincipalInfo(id=account.name, 121 125 title=account.title, … … 157 161 return IUserAccount(student) 158 162 163 class PasswordChangeCredentialsPlugin(grok.GlobalUtility, 164 SessionCredentialsPlugin): 165 grok.provides(ICredentialsPlugin) 166 grok.name('student_pw_change') 167 168 loginpagename = 'login' 169 loginfield = 'student_id' 170 passwordfield = 'form.password' 171 172 def extractCredentials(self, request): 173 result = super( 174 PasswordChangeCredentialsPlugin, self).extractCredentials( 175 request) 176 if isinstance(result, dict): 177 # Add a marker for the authentication plugin 178 result['reset'] = True 179 return result 180 159 181 class StudentsAuthenticatorSetup(grok.GlobalUtility): 160 182 """Register or unregister student authentication for a PAU. … … 165 187 166 188 def register(self, pau): 189 plugins = list(pau.credentialsPlugins) 190 plugins.insert(0, 'student_pw_change') 191 pau.credentialsPlugins = tuple(plugins) 167 192 plugins = list(pau.authenticatorPlugins) 168 193 plugins.append('students') -
main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/tests/test_browser.py
r6707 r6713 282 282 self.browser.open(self.login_path) 283 283 self.browser.getControl(name="form.login").value = self.test_student_id 284 self.browser.getControl(name=" password").value = 'new_password'284 self.browser.getControl(name="form.password").value = 'new_password' 285 285 self.browser.getControl("Login").click() 286 286 self.assertEqual(self.browser.url, self.student_path) 287 287 self.assertTrue('You logged in' in self.browser.contents) 288 289 return 288 return
Note: See TracChangeset for help on using the changeset viewer.