From: Benoît Pin <pin@cri.ensmp.fr> Date: Wed, 31 Jul 2013 09:06:53 +0000 (+0200) Subject: Implémentation complète (mais minimale) de la réinitialisation de mot de passe. X-Git-Url: https://scm.cri.minesparis.psl.eu/git/Plinn.git/commitdiff_plain/125a6289be7a631a256f948bda5415451aca6d98?ds=inline;hp=63f5e85cdbd05ac9a00a6dab60548c226981fb62 Implémentation complète (mais minimale) de la réinitialisation de mot de passe. --- 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 @@ +<html metal:use-macro="here/main_template/macros/master" + xmlns:tal="http://xml.zope.org/namespaces/tal" + xmlns:metal="http://xml.zope.org/namespaces/metal" + xmlns:i18n="http://xml.zope.org/namespaces/i18n"> + <head> + <title>Password reset form</title> + <meta http-equiv="content-type" content="text/html;charset=utf-8" /> + + </head> + <body i18n:domain="plinn"> + <div metal:fill-slot="main_no_tabs" tal:omit-tag=""> + <form tal:attributes="action options/action"> + <h2 i18n:translate="">Password resetting</h2> + <table class="TwoColumnForm"> + <tr> + <td colspan="2"> + <dl class="FieldHelp"> + <dd i18n:translate=""> + Please enter a new password and clic on "Validate" button. + </dd> + </dl> + </td> + </tr> + <tr> + <th i18n:translate="">Password</th> + <td> + <input type="password" name="password"/> + </td> + </tr> + <tr> + <th i18n:translate="">Confirm</th> + <td> + <input type="password" name="confirm"/> + </td> + </tr> + <tr> + <td><br/></td> + <td> + <input type="submit" name="validate" value="Validate" i18n:attributes="value"/> + </td> + </tr> + </table> + </form> + </div> + </body> +</html>