From 125a6289be7a631a256f948bda5415451aca6d98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 31 Jul 2013 11:06:53 +0200 Subject: [PATCH] =?utf8?q?Impl=C3=A9mentation=20compl=C3=A8te=20(mais=20mi?= =?utf8?q?nimale)=20de=20la=20r=C3=A9initialisation=20de=20mot=20de=20pass?= =?utf8?q?e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- RegistrationTool.py | 9 ++--- skins/control/reset_password_control.py | 9 +++++ skins/generic/password_reset_form.py | 19 ++++++++++ skins/generic/password_reset_template.pt | 46 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 skins/control/reset_password_control.py create mode 100644 skins/generic/password_reset_form.py create mode 100644 skins/generic/password_reset_template.pt diff --git a/RegistrationTool.py b/RegistrationTool.py index c35cb6a..b46a13b 100644 --- a/RegistrationTool.py +++ b/RegistrationTool.py @@ -234,16 +234,13 @@ class RegistrationTool(BaseRegistrationTool) : security.declarePublic('resetPassword') - def resetPassword(self, userid, uuid, password, confirm) : + def resetPassword(self, uuid, password, confirm) : record = self._passwordResetRequests.get(uuid) if not record : return _('Invalid reset password request.') - recUserid, expiration = record - - if recUserid != userid : - return _('Invalid userid.') - + userid, expiration = record + now = DateTime() if expiration < now : self.clearExpiredPasswordResetRequests() return _('Your reset password request has expired. You can ask a new one.') diff --git a/skins/control/reset_password_control.py b/skins/control/reset_password_control.py new file mode 100644 index 0000000..f903e24 --- /dev/null +++ b/skins/control/reset_password_control.py @@ -0,0 +1,9 @@ +##parameters=uuid='', password='', confirm='', **kw +from Products.CMFCore.utils import getUtilityByInterfaceName +rtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool') + +msg = rtool.resetPassword(uuid, password, confirm) +if msg : + return context.setStatus(False, msg) +else : + return True \ No newline at end of file diff --git a/skins/generic/password_reset_form.py b/skins/generic/password_reset_form.py new file mode 100644 index 0000000..b783b63 --- /dev/null +++ b/skins/generic/password_reset_form.py @@ -0,0 +1,19 @@ +##parameters=validate='' +from Products.CMFCore.utils import getUtilityByInterfaceName +utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool') +atool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IActionsTool') + +form = context.REQUEST.form +uuid = traverse_subpath[0] + +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 + +options = {} +options['uuid'] = uuid +options['action'] = '%s/password_reset_form/%s' % (utool(), uuid) + +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 new file mode 100644 index 0000000..30c46b4 --- /dev/null +++ b/skins/generic/password_reset_template.pt @@ -0,0 +1,46 @@ + + + Password reset form + + + + +
+
+

Password resetting

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

+ +
+
+
+ + -- 2.20.1