[FIX] Trunk backport: properly record UTC login date, courtesy of Ian Beardslee

lp bug: https://launchpad.net/bugs/967829 fixed

bzr revid: odo@openerp.com-20120331015249-9pvyin8x4tlymois
This commit is contained in:
Olivier Dony 2012-03-31 03:52:49 +02:00
parent b2f8eb7c19
commit c541f500a3
3 changed files with 13 additions and 7 deletions

View File

@ -65,8 +65,10 @@ class res_users(osv.osv):
return result
else:
with utils.cursor(db) as cr:
cr.execute('UPDATE res_users SET date=now() WHERE login=%s AND openid_key=%s AND active=%s RETURNING id',
(tools.ustr(login), tools.ustr(password), True))
cr.execute("""UPDATE res_users
SET date=now() AT TIME ZONE 'UTC'
WHERE login=%s AND openid_key=%s AND active=%s RETURNING id""",
(tools.ustr(login), tools.ustr(password), True))
res = cr.fetchone()
cr.commit()
return res[0] if res else False

View File

@ -211,9 +211,11 @@ class users(osv.osv):
encrypted_pw = encrypt_md5(password, salt)
# Check if the encrypted password matches against the one in the db.
cr.execute('UPDATE res_users SET date=now() ' \
'WHERE id=%s AND password=%s AND active RETURNING id',
(int(id), encrypted_pw.encode('utf-8')))
cr.execute("""UPDATE res_users
SET date=now() AT TIME ZONE 'UTC'
WHERE id=%s AND password=%s AND active
RETURNING id""",
(int(id), encrypted_pw.encode('utf-8')))
res = cr.fetchone()
cr.commit()

View File

@ -256,8 +256,10 @@ class users(osv.osv):
user_id = ldap_obj.get_or_create_user(
cr, SUPERUSER_ID, conf, login, entry)
if user_id:
cr.execute('UPDATE res_users SET date=now() WHERE '
'login=%s', (tools.ustr(login),))
cr.execute("""UPDATE res_users
SET date=now() AT TIME ZONE 'UTC'
WHERE login=%s""",
(tools.ustr(login),))
cr.commit()
break
cr.close()