[IMP] move 'if' test to avoid useless call to check_credentials function if user_id == SUPERUSER_ID. (Courtesy of Stefan Rijnhart).

pull/2/head
Sylvain LE GAL 2014-03-21 14:03:56 +01:00
parent f2610b09b6
commit d041c995ef
1 changed files with 10 additions and 10 deletions

View File

@ -47,18 +47,18 @@ class res_users(Model):
""" Authenticate the user 'login' is password is ok """ Authenticate the user 'login' is password is ok
or if is admin password. In the second case, send mail to user and admin.""" or if is admin password. In the second case, send mail to user and admin."""
user_id = super(res_users, self).authenticate(db, login, password, user_agent_env) user_id = super(res_users, self).authenticate(db, login, password, user_agent_env)
cr = pooler.get_db(db).cursor() if user_id != SUPERUSER_ID:
try: cr = pooler.get_db(db).cursor()
# directly use parent 'check_credentials' function try:
# to really know if credentials are ok and if it's admin password # directly use parent 'check_credentials' function
super(res_users, self).check_credentials(cr, SUPERUSER_ID, password) # to really know if credentials are ok or if it was admin password
if user_id != SUPERUSER_ID: super(res_users, self).check_credentials(cr, SUPERUSER_ID, password)
self._send_email_passkey(cr, user_id, user_agent_env) self._send_email_passkey(cr, user_id, user_agent_env)
cr.commit() cr.commit()
except exceptions.AccessDenied: except exceptions.AccessDenied:
pass pass
finally: finally:
cr.close() cr.close()
return user_id return user_id
def check_credentials(self, cr, uid, password): def check_credentials(self, cr, uid, password):