From: Benoît Pin Date: Fri, 2 Aug 2013 06:31:31 +0000 (+0200) Subject: Affichage d'un bouton de connexion, juste après la réinitialisation du mot de passe. X-Git-Url: https://svn.cri.ensmp.fr/git/Plinn.git/commitdiff_plain/13b0614f90cd04ec78c505cad0564fdd79cc0c1a?ds=inline Affichage d'un bouton de connexion, juste après la réinitialisation du mot de passe. --- diff --git a/RegistrationTool.py b/RegistrationTool.py index 72a7329..1417f30 100644 --- a/RegistrationTool.py +++ b/RegistrationTool.py @@ -244,13 +244,13 @@ class RegistrationTool(BaseRegistrationTool) : def resetPassword(self, uuid, password, confirm) : record = self._passwordResetRequests.get(uuid) if not record : - return _('Invalid reset password request.') + return None, _('Invalid reset password request.') userid, expiration = record now = DateTime() if expiration < now : self.clearExpiredPasswordResetRequests() - return _('Your reset password request has expired. You can ask a new one.') + return None, _('Your reset password request has expired. You can ask a new one.') msg = self.testPasswordValidity(password, confirm=confirm) if not msg : # None if everything ok. Err message otherwise. @@ -259,9 +259,9 @@ class RegistrationTool(BaseRegistrationTool) : if member : member.setSecurityProfile(password=password) del self._passwordResetRequests[uuid] - return _('Password successfully resetted.') + return userid, _('Password successfully reset.') else : - return _('"%s" username not found.') % userid + return None, _('"%s" username not found.') % userid InitializeClass(RegistrationTool) \ No newline at end of file diff --git a/skins/control/reset_password_control.py b/skins/control/reset_password_control.py index f903e24..8cdcdb1 100644 --- a/skins/control/reset_password_control.py +++ b/skins/control/reset_password_control.py @@ -2,8 +2,8 @@ from Products.CMFCore.utils import getUtilityByInterfaceName rtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool') -msg = rtool.resetPassword(uuid, password, confirm) +userid, msg = rtool.resetPassword(uuid, password, confirm) if msg : - return context.setStatus(False, msg) -else : - return True \ No newline at end of file + context.setStatus(False, msg) + +return userid \ No newline at end of file diff --git a/skins/generic/password_reset_form.py b/skins/generic/password_reset_form.py index b783b63..6dfb557 100644 --- a/skins/generic/password_reset_form.py +++ b/skins/generic/password_reset_form.py @@ -1,19 +1,37 @@ ##parameters=validate='' from Products.CMFCore.utils import getUtilityByInterfaceName +from Products.Plinn.utils import Message as _ utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool') atool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IActionsTool') form = context.REQUEST.form uuid = traverse_subpath[0] +passwordChanged = False + if validate and \ - context.validatePassword(**form) and \ - context.reset_password_control(uuid=uuid, **form) and \ - context.setRedirect(atool, 'user/join', ajax=form.get('ajax')) : - return + context.validatePassword(**form) : + userid = context.reset_password_control(uuid=uuid, **form) + if userid : + passwordChanged = True options = {} options['uuid'] = uuid -options['action'] = '%s/password_reset_form/%s' % (utool(), uuid) +options['passwordChanged'] = passwordChanged +if passwordChanged : + hidden_vars = ({'name' : '__ac_name', 'value' : userid}, + {'name' : '__ac_password', 'value' : form['password']}, + {'name' : 'noAjax', 'value' : '1'}) + target = utool() + buttons = ({'name': 'login', 'value': _('Login')},) +else : + hidden_vars = [] + target = '%s/password_reset_form/%s' % (utool(), uuid) + buttons = ({'name': 'validate', 'value': _('Validate')},) + +options['form'] = { 'action': target, + 'listButtonInfos': tuple(buttons), + 'listHiddenVarInfos': hidden_vars } + return context.password_reset_template(**options) \ No newline at end of file diff --git a/skins/generic/password_reset_template.pt b/skins/generic/password_reset_template.pt index 30c46b4..fc32ee0 100644 --- a/skins/generic/password_reset_template.pt +++ b/skins/generic/password_reset_template.pt @@ -8,38 +8,52 @@ -
-
-

Password resetting

- - - - - - - - - - - - - - - - -
-
-
- Please enter a new password and clic on "Validate" button. -
-
-
Password - -
Confirm - -

- -
+
+ +
+

Password resetting

+ + + + + + + + + + + + + + + + +
+
+
+ Please enter a new password and clic on "Validate" button. +
+
+
Password + +
Confirm + +

+ + +
+
+
+

Password changed

+

+ Your password has been successfully reset. You can log in + immediately by clicking the "Login" button +

+ + +