+ cr.execute('SELECT id FROM ir_module_module WHERE name = \'auth_openid\' and state = \'installed\'')
+ if cr.rowcount:
+ cr.execute( 'SELECT password, id FROM res_users WHERE login=%s AND openid_key = %s AND active',
+ (login.encode('utf-8'),password.encode('utf-8')))
+ if cr.rowcount:
+ # Check if the encrypted password matches against the one in the db.
+ cr.execute("""UPDATE res_users
+ SET login_date=now() AT TIME ZONE 'UTC'
+ WHERE id=%s AND openid_key=%s AND active
+ RETURNING id""",
+ (int(id), password.encode('utf-8')))
+ res = cr.fetchone()
+ cr.commit()
+
+ if res:
+ return res[0]