return str(uuid4())
security.declarePublic('requestPasswordReset')
- def requestPasswordReset(self, userid, initial=False):
+ def requestPasswordReset(self, userid, initial=False, came_from=''):
""" add uuid / (userid, expiration) pair
if ok: send an email to member. returns error message otherwise.
"""
uuid = str(uuid4())
while self._passwordResetRequests.has_key(uuid) :
uuid = str(uuid4())
- self._passwordResetRequests[uuid] = (userid, DateTime() + 1)
+ self._passwordResetRequests[uuid] = (userid, DateTime() + 1, came_from)
utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool')
ptool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
# fuck : mailhost récupéré avec getUtilityByInterfaceName n'est pas correctement
def clearExpiredPasswordResetRequests(self):
now = DateTime()
for uuid, record in self._passwordResetRequests.items() :
- userid, date = record
+ date = record[1]
if date < now :
del self._passwordResetRequests[uuid]
if not record :
return None, _('Invalid reset password request.')
- userid, expiration = record
+ userid, expiration, came_from = record
now = DateTime()
if expiration < now :
self.clearExpiredPasswordResetRequests()
if member :
member.setSecurityProfile(password=password)
del self._passwordResetRequests[uuid]
- return userid, _('Password successfully updated.')
+ return {'userid': userid, 'came_from' : came_from}, _('Password successfully updated.')
else :
return None, _('"${userid}" username not found.', mapping={'userid': userid})
else :
'name' : name,
'email': member_email})
if validate_email :
- rtool.requestPasswordReset(member_id, initial=True)
+ rtool.requestPasswordReset(member_id, initial=True, came_from=came_from)
context.setStatus(True, _('Success!'))
is_newmember = True
is_anon = False
except ValueError, errmsg:
+ raise
context.setStatus(False, errmsg)
options = {}
passwordChanged = False
if validate :
- userid = context.reset_password_control(uuid=uuid, **form)
- if userid :
+ infos = context.reset_password_control(uuid=uuid, **form)
+ if infos :
passwordChanged = True
options = {}
options['uuid'] = uuid
options['passwordChanged'] = passwordChanged
if passwordChanged :
- hidden_vars = ({'name' : '__ac_name', 'value' : userid},
+ hidden_vars = ({'name' : '__ac_name', 'value' : infos['userid']},
{'name' : '__ac_password', 'value' : form['password']},
+ {'name' : 'came_from', 'value' : infos['came_from']},
{'name' : 'noAjax', 'value' : '1'})
- target = utool()
+ target = atool.getActionInfo('user/logged_in')['url']
buttons = ({'name': 'login', 'value': _(' Login ')},)
else :
hidden_vars = []