summaryrefslogtreecommitdiff
path: root/addons/base_crypt
diff options
context:
space:
mode:
authorArnaud Pineux <api@openerp.com>2012-11-15 16:14:10 +0100
committerArnaud Pineux <api@openerp.com>2012-11-15 16:14:10 +0100
commit87899acfa8128b636fd3c1932e63fe3eccaa874c (patch)
treeefae830bcf0c5947b4f4c0c40d93a52d14e4682a /addons/base_crypt
parent27c672b1fc1556602764d066de4b63cdb1eeb158 (diff)
[FIX] openID and Crypt
lp bug: https://launchpad.net/bugs/1026784 fixed bzr revid: api@openerp.com-20121115151410-b2mey3wystp5zha0
Diffstat (limited to 'addons/base_crypt')
-rw-r--r--addons/base_crypt/crypt.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py
index 14e029eb988..a1c7519958c 100644
--- a/addons/base_crypt/crypt.py
+++ b/addons/base_crypt/crypt.py
@@ -201,6 +201,20 @@ class users(osv.osv):
# Return early if no one has a login name like that.
return False
+ # Check if the authentification is made with OpenID. In this case, don't encrypt the password
+ cr.execute('SELECT id FROM ir_module_module WHERE name = \'auth_openid\' and state = \'installed\'')
+ if cr.rowcount:
+ cr.execute( 'SELECT password, id FROM res_users WHERE login=%s AND openid_key = %s AND active',
+ (login.encode('utf-8'),password.encode('utf-8')))
+ if cr.rowcount:
+ # Check if the encrypted password matches against the one in the db.
+ cr.execute("""UPDATE res_users SET login_date=now() AT TIME ZONE 'UTC' WHERE id=%s AND openid_key=%s AND active RETURNING id""",
+ (int(id), password.encode('utf-8')))
+ res = cr.fetchone()
+ cr.commit()
+ if res:
+ return res[0]
+
stored_pw = self.maybe_encrypt(cr, stored_pw, id)
if not stored_pw: