Commit c6032064 authored by Aurel's avatar Aurel

add method to check password


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16046 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 977b86d7
...@@ -42,11 +42,17 @@ try: ...@@ -42,11 +42,17 @@ try:
except ImportError: except ImportError:
PluggableAuthService = None PluggableAuthService = None
try : try:
from AccessControl.AuthEncoding import pw_encrypt from AccessControl.AuthEncoding import pw_encrypt
except ImportError: except ImportError:
pw_encrypt = lambda pw:pw pw_encrypt = lambda pw:pw
try:
from AccessControl.AuthEncoding import pw_validate
except ImportError:
pw_validate = lambda reference, attempt: reference == attempt
#class Person(Node, XMLObject): #class Person(Node, XMLObject):
class Person(XMLObject): class Person(XMLObject):
""" """
...@@ -182,6 +188,15 @@ class Person(XMLObject): ...@@ -182,6 +188,15 @@ class Person(XMLObject):
portal_caches = getToolByName(self.getPortalObject(), 'portal_caches') portal_caches = getToolByName(self.getPortalObject(), 'portal_caches')
portal_caches.clearCache(cache_factory_list=('erp5_content_short', )) portal_caches.clearCache(cache_factory_list=('erp5_content_short', ))
security.declareProtected(Permissions.SetOwnPassword, 'checkPassword')
def checkPassword(self, value) :
"""
Check the password, usefull when changing password
"""
if value is not None :
return pw_validate(self.getPassword(), value)
return False
security.declareProtected(Permissions.SetOwnPassword, 'setPassword') security.declareProtected(Permissions.SetOwnPassword, 'setPassword')
def setPassword(self, value) : def setPassword(self, value) :
""" """
......
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