summaryrefslogtreecommitdiff
path: root/addons/auth_crypt/auth_crypt.py
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2013-09-11 13:07:55 +0200
committerMartin Trigaux <mat@openerp.com>2013-09-11 13:07:55 +0200
commitc48504fdba1ef68033c5e6c3b7929ea4e153d4b7 (patch)
tree471c4c37f5b76a4f034b5de805655d5fc5dcf867 /addons/auth_crypt/auth_crypt.py
parent9349ba848497b9c5b7ded809a4db6b1e3b26b6a6 (diff)
parent3fa90321e11d28df4e2b874ddfa450dc73e8e0af (diff)
[MERGE] sync with trunk (state -> stage removed some test)
bzr revid: mat@openerp.com-20130911110755-zf3ytf9m27im6x9k
Diffstat (limited to 'addons/auth_crypt/auth_crypt.py')
-rw-r--r--addons/auth_crypt/auth_crypt.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/addons/auth_crypt/auth_crypt.py b/addons/auth_crypt/auth_crypt.py
index d0a4fda9632..4651d27fe7d 100644
--- a/addons/auth_crypt/auth_crypt.py
+++ b/addons/auth_crypt/auth_crypt.py
@@ -120,7 +120,7 @@ class res_users(osv.osv):
def set_pw(self, cr, uid, id, name, value, args, context):
if value:
encrypted = md5crypt(value, gen_salt())
- cr.execute('update res_users set password_crypt=%s where id=%s', (encrypted, int(id)))
+ cr.execute("update res_users set password='', password_crypt=%s where id=%s", (encrypted, id))
del value
def get_pw( self, cr, uid, ids, name, args, context ):
@@ -143,7 +143,7 @@ class res_users(osv.osv):
cr.execute('SELECT password, password_crypt FROM res_users WHERE id=%s AND active', (uid,))
if cr.rowcount:
stored_password, stored_password_crypt = cr.fetchone()
- if password and not stored_password_crypt:
+ if stored_password and not stored_password_crypt:
salt = gen_salt()
stored_password_crypt = md5crypt(stored_password, salt)
cr.execute("UPDATE res_users SET password='', password_crypt=%s WHERE id=%s", (stored_password_crypt, uid))
@@ -151,14 +151,15 @@ class res_users(osv.osv):
return super(res_users, self).check_credentials(cr, uid, password)
except openerp.exceptions.AccessDenied:
# check md5crypt
- if stored_password_crypt[:len(magic_md5)] == magic_md5:
- salt = stored_password_crypt[len(magic_md5):11]
- if stored_password_crypt == md5crypt(password, salt):
- return
- elif stored_password_crypt[:len(magic_md5)] == magic_sha256:
- salt = stored_password_crypt[len(magic_md5):11]
- if stored_password_crypt == md5crypt(password, salt):
- return
+ if stored_password_crypt:
+ if stored_password_crypt[:len(magic_md5)] == magic_md5:
+ salt = stored_password_crypt[len(magic_md5):11]
+ if stored_password_crypt == md5crypt(password, salt):
+ return
+ elif stored_password_crypt[:len(magic_md5)] == magic_sha256:
+ salt = stored_password_crypt[len(magic_md5):11]
+ if stored_password_crypt == md5crypt(password, salt):
+ return
# Reraise password incorrect
raise