Changeset 8858 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 30 Jun 2012, 07:39:07 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r8857 r8858 26 26 import time 27 27 import re 28 from urllib import urlencode 28 29 from zope import schema 29 30 from zope.authentication.interfaces import ( … … 67 68 from waeup.kofa.authentication import get_principal_role_manager 68 69 from waeup.kofa.utils.helpers import get_user_account, msave 70 from waeup.kofa.mandates.mandate import PasswordMandate 69 71 70 72 grok.context(IKofaObject) … … 2124 2126 # Change password 2125 2127 kofa_utils = getUtility(IKofaUtils) 2126 pwd = kofa_utils.genPassword() 2127 2128 ###: To be changed 2129 IUserAccount(user).setPassword(pwd) 2130 2131 2132 # Send email with new credentials 2133 msg = _('You have successfully changed your password for the') 2134 login_url = self.url(grok.getSite(), 'login') 2135 url_info = u'Login: %s' % login_url 2128 password = kofa_utils.genPassword() 2129 mandate = PasswordMandate() 2130 mandate.params['password'] = password 2131 mandate.params['user'] = user 2132 site = grok.getSite() 2133 site['mandates'].addMandate(mandate) 2134 # Send email with credentials 2135 args = {'mandate_id':mandate.mandate_id} 2136 mandate_url = self.url(site) + '/mandate?%s' % urlencode(args) 2137 url_info = u'Confirmation link: %s' % mandate_url 2138 msg = _('You have successfully requested a password for the') 2136 2139 success = kofa_utils.sendCredentials( 2137 IUserAccount(user),p wd,url_info,msg)2140 IUserAccount(user),password,url_info,msg) 2138 2141 if success: 2139 2142 self.flash(_('An email with your user name and password ' + -
main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
r8857 r8858 55 55 56 56 def _setPassword(self): 57 user _id = self.params.get('user_id', None)57 user = self.params.get('user', None) 58 58 pwd = self.params.get('password', None) 59 user_type = self.params.get('user_type', None)60 user = None61 if user_type == 'student':62 user = grok.getSite()['students'].get(user_id, None)63 elif user_type == 'officer':64 user = grok.getSite()['users'].get(user_id, None)65 59 if user and pwd: 66 IUserAccount(user).setPassword(pwd) 67 return True 60 try: 61 IUserAccount(user).setPassword(pwd) 62 return True 63 except: 64 return False 68 65 return False 69 66 -
main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py
r8857 r8858 99 99 # Add and execute a perfect mandate 100 100 mandate = PasswordMandate() 101 mandate.params['user _id'] = student.student_id101 mandate.params['user'] = student 102 102 mandate.params['password'] = 'mypwd1' 103 mandate.params['user_type'] = 'student'104 103 self.app['mandates'].addMandate(mandate) 105 104 msg = mandate.execute() … … 115 114 officer = self.app['users']['bob'] 116 115 mandate = PasswordMandate() 117 mandate.params['user _id'] = 'bob'116 mandate.params['user'] = officer 118 117 mandate.params['password'] = 'mypwd1' 119 mandate.params['user_type'] = 'officer'120 118 self.app['mandates'].addMandate(mandate) 121 119 msg = mandate.execute() … … 142 140 self.app['students'].addStudent(student) 143 141 mandate = PasswordMandate() 144 mandate.params['user_id'] = student.student_id 145 mandate.params['user_type'] = 'student' 142 mandate.params['user'] = student 146 143 mandate.params['password'] = 'mypwd1' 147 144 self.app['mandates'].addMandate(mandate) -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r8857 r8858 1989 1989 mandate = PasswordMandate() 1990 1990 mandate.params['password'] = password 1991 mandate.params['student_id'] = student.student_id 1992 mandate.params['user_type'] = 'student' 1991 mandate.params['user'] = student 1993 1992 site = grok.getSite() 1994 1993 site['mandates'].addMandate(mandate)
Note: See TracChangeset for help on using the changeset viewer.