Commit 9801d402 authored by Jérome Perrin's avatar Jérome Perrin

PasswordTool: new method analyzePassword

When authentication policy is in used, this method allows for checking
that the provided password can be used for the login referenced by this
password_key
parent 033da3c0
...@@ -229,6 +229,25 @@ class PasswordTool(BaseTool): ...@@ -229,6 +229,25 @@ class PasswordTool(BaseTool):
if date < current_date: if date < current_date:
del password_request_dict[key] del password_request_dict[key]
security.declarePublic('analyzePassword')
def analyzePassword(self, password, password_key):
"""Analyze password validity in the context of the login.
Returns a list of messages as returned by IEncryptedPassword.analyzePassword
"""
portal = self.getPortalObject()
if not portal.portal_preferences.isAuthenticationPolicyEnabled():
return []
try:
register_user_login, expiration_date = self._password_request_dict[
password_key]
except KeyError:
return []
user_list = portal.acl_users.erp5_users.getUserByLogin(register_user_login)
if user_list:
return user_list[0].analyzePassword(password)
return []
security.declarePublic('changeUserPassword') security.declarePublic('changeUserPassword')
def changeUserPassword(self, password, password_key, password_confirm=None, def changeUserPassword(self, password, password_key, password_confirm=None,
user_login=None, REQUEST=None, **kw): user_login=None, REQUEST=None, **kw):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment