[IMP] base: properly handle API keys on inactive users
closes odoo/odoo#66512 X-original-commit: baebf5814425cce6a9481b4efec5248bbba3ea64 Signed-off-by: Olivier Dony (odo) <odo@openerp.com> Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -1643,7 +1643,11 @@ class APIKeys(models.Model):
|
||||
def _check_credentials(self, *, scope, key):
|
||||
assert scope, "scope is required"
|
||||
index = key[:INDEX_SIZE]
|
||||
self.env.cr.execute('SELECT user_id, key FROM res_users_apikeys WHERE index = %s AND (scope IS NULL OR scope = %s)', [index, scope])
|
||||
self.env.cr.execute('''
|
||||
SELECT user_id, key
|
||||
FROM res_users_apikeys INNER JOIN res_users u ON (u.id = user_id)
|
||||
WHERE u.active and index = %s AND (scope IS NULL OR scope = %s)
|
||||
''', [index, scope])
|
||||
for user_id, current_key in self.env.cr.fetchall():
|
||||
if KEY_CRYPT_CONTEXT.verify(key, current_key):
|
||||
return user_id
|
||||
|
||||
Reference in New Issue
Block a user