From f6d33133b4aad57e7050117a99e2adad711e118b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Fri, 17 Apr 2015 10:08:32 +0200 Subject: [PATCH] =?utf8?q?8=20caract=C3=A8res=20requis=20pour=20un=20mot?= =?utf8?q?=20de=20passe.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Products/Plinn/RegistrationTool.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Products/Plinn/RegistrationTool.py b/Products/Plinn/RegistrationTool.py index fff500e..3e04db1 100644 --- a/Products/Plinn/RegistrationTool.py +++ b/Products/Plinn/RegistrationTool.py @@ -35,6 +35,7 @@ from Products.CMFCore.exceptions import AccessControl_Unauthorized from Products.CMFDefault.exceptions import EmailAddressInvalid from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getUtilityByInterfaceName +from Products.CMFCore.utils import _checkPermission from Products.CMFDefault.utils import checkEmailAddress from Products.GroupUserFolder.GroupsToolPermissions import ManageGroups from Products.Plinn.utils import Message as _ @@ -217,6 +218,27 @@ class RegistrationTool(BaseRegistrationTool) : BaseRegistrationTool.addMember(self, id, password, roles=roles, domains=domains, properties=properties) + security.declarePublic( 'testPasswordValidity' ) + def testPasswordValidity(self, password, confirm=None): + + """ Verify that the password satisfies the portal's requirements. + + o If the password is valid, return None. + o If not, return a string explaining why. + """ + if not password: + return _(u'You must enter a password.') + + if len(password) < 8 and not _checkPermission(ManagePortal, self): + return _(u'Your password must contain at least 8 characters.') + + if confirm is not None and confirm != password: + return _(u'Your password and confirmation did not match. ' + u'Please try again.') + + return None + + def afterAdd(self, member, id, password, properties): """ notify member creation """ -- 2.20.1