diff options
| author | Ajay Chauhan (OpenERP) <cha@tinyerp.com> | 2012-10-23 10:49:57 +0530 |
|---|---|---|
| committer | Ajay Chauhan (OpenERP) <cha@tinyerp.com> | 2012-10-23 10:49:57 +0530 |
| commit | 74ee6c9c8f2fe3d87c8e5cfce81a30e2152a8ad8 (patch) | |
| tree | 7d116c42424dd56469997d981e7ebbf074d6743d /addons/base_crypt | |
| parent | 3d9e153cd088943b3595c21a405e2232ffd79711 (diff) | |
| parent | c55438e695d03854ebf1b82aa0d6b33b3dc278f0 (diff) | |
[MERGE] merge with lp:openobject-addons
bzr revid: cha@tinyerp.com-20121023051957-v8mdl714cnne8y2y
Diffstat (limited to 'addons/base_crypt')
| -rw-r--r-- | addons/base_crypt/crypt.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py index 81a60a5dd5f..14e029eb988 100644 --- a/addons/base_crypt/crypt.py +++ b/addons/base_crypt/crypt.py @@ -140,18 +140,20 @@ class users(osv.osv): # Add handlers for 'input_pw' field. def set_pw(self, cr, uid, id, name, value, args, context): - if not value: - raise osv.except_osv(_('Error!'), _("You have to specify a password.")) + if value: + obj = pooler.get_pool(cr.dbname).get('res.users') + if not hasattr(obj, "_salt_cache"): + obj._salt_cache = {} - obj = pooler.get_pool(cr.dbname).get('res.users') - if not hasattr(obj, "_salt_cache"): - obj._salt_cache = {} + salt = obj._salt_cache[id] = gen_salt() + encrypted = encrypt_md5(value, salt) - salt = obj._salt_cache[id] = gen_salt() - encrypted = encrypt_md5(value, salt) + else: + #setting a password to '' is allowed. It can be used to inactivate the classic log-in of the user + #while the access can still be granted by another login method (openid...) + encrypted = '' cr.execute('update res_users set password=%s where id=%s', (encrypted.encode('utf-8'), int(id))) - cr.commit() del value def get_pw( self, cr, uid, ids, name, args, context ): |
