From 21ffa7b46d128cb73bd7e8c924a273e63b830c97 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Thu, 12 Jul 2012 17:54:14 +0200 Subject: [PATCH] [gen] Added UserWrapper.checkPassword allowing to check if a password is the right one for a user. --- gen/wrappers/UserWrapper.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gen/wrappers/UserWrapper.py b/gen/wrappers/UserWrapper.py index 0239dc2..87ada11 100644 --- a/gen/wrappers/UserWrapper.py +++ b/gen/wrappers/UserWrapper.py @@ -78,6 +78,13 @@ class UserWrapper(AbstractWrapper): (msgPart, self.user.getId(), login)) return newPassword + def checkPassword(self, clearPassword): + '''Returns True if p_clearPassword is the correct password for this + user.''' + encryptedPassword = self.getZopeUser()._getPassword() + from AccessControl.AuthEncoding import pw_validate + return pw_validate(encryptedPassword, clearPassword) + def setLogin(self, oldLogin, newLogin): '''Changes the login of this user from p_oldLogin to p_newLogin.''' self.login = newLogin