From ae75bab9028d6321710c42da338cef25c7afe576 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Tue, 28 Apr 2015 18:14:19 +0200 Subject: [PATCH] =?utf8?q?Prise=20en=20charge=20de=20la=20redirection=20ve?= =?utf8?q?rs=20=C2=AB=C2=A0came=5Ffrom=C2=A0=C2=BB=20lors=20de=20la=20r?= =?utf8?q?=C3=A9-initialisation=20de=20mot=20de=20passe.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Products/Plinn/RegistrationTool.py | 10 +++++----- Products/Plinn/skins/custom_generic/join_form.py | 3 ++- Products/Plinn/skins/generic/password_reset_form.py | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Products/Plinn/RegistrationTool.py b/Products/Plinn/RegistrationTool.py index 3e04db1..738d2ee 100644 --- a/Products/Plinn/RegistrationTool.py +++ b/Products/Plinn/RegistrationTool.py @@ -254,7 +254,7 @@ class RegistrationTool(BaseRegistrationTool) : 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. """ @@ -274,7 +274,7 @@ class RegistrationTool(BaseRegistrationTool) : 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 @@ -311,7 +311,7 @@ class RegistrationTool(BaseRegistrationTool) : 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] @@ -322,7 +322,7 @@ class RegistrationTool(BaseRegistrationTool) : if not record : return None, _('Invalid reset password request.') - userid, expiration = record + userid, expiration, came_from = record now = DateTime() if expiration < now : self.clearExpiredPasswordResetRequests() @@ -335,7 +335,7 @@ class RegistrationTool(BaseRegistrationTool) : 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 : diff --git a/Products/Plinn/skins/custom_generic/join_form.py b/Products/Plinn/skins/custom_generic/join_form.py index f7cdead..3badc16 100644 --- a/Products/Plinn/skins/custom_generic/join_form.py +++ b/Products/Plinn/skins/custom_generic/join_form.py @@ -37,11 +37,12 @@ if add : '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 = {} diff --git a/Products/Plinn/skins/generic/password_reset_form.py b/Products/Plinn/skins/generic/password_reset_form.py index 9cb4b1d..7bd487a 100644 --- a/Products/Plinn/skins/generic/password_reset_form.py +++ b/Products/Plinn/skins/generic/password_reset_form.py @@ -10,18 +10,19 @@ uuid = traverse_subpath[0] 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 = [] -- 2.20.1