diff --git a/bin/service/security.py b/bin/service/security.py index ee856e8831b..b956914a3dc 100644 --- a/bin/service/security.py +++ b/bin/service/security.py @@ -52,13 +52,14 @@ def check_super(passwd): raise ExceptionNoTb('AccessDenied') def check(db, uid, passwd): - if _uid_cache.get(db, {}).get(uid) and _uid_cache.get(db, {}).get(uid) == passwd: + cached_pass = _uid_cache.get(db, {}).get(uid) + if (cached_pass is not None) and cached_pass == passwd: return True cr = pooler.get_db(db).cursor() if passwd: - cr.execute('select count(*) from res_users where id=%s and password=%s', (int(uid), passwd)) + cr.execute('select count(1) from res_users where id=%s and password=%s and active=%s', (int(uid), passwd, True)) else: - cr.execute('select count(*) from res_users where id=%s and password is null', (int(uid),)) + cr.execute('select count(1) from res_users where id=%s and password is null and active=%s', (int(uid), True)) res = cr.fetchone()[0] cr.close() if not bool(res): diff --git a/bin/tools/translate.py b/bin/tools/translate.py index f12af476b94..ff8d2bcf791 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -125,7 +125,11 @@ def translate(cr, name, source_type, lang, source=None): class GettextAlias(object): def __call__(self, source): - frame = inspect.stack()[1][0] + try: + frame = inspect.stack()[1][0] + except: + return source + cr = frame.f_locals.get('cr') try: lang = (frame.f_locals.get('context') or {}).get('lang', False)