From e2cf852150591ae6043076412e48f6cfbe4ef697 Mon Sep 17 00:00:00 2001 From: "Thomas Becquevort (thbe)" Date: Tue, 26 Dec 2023 13:59:22 +0100 Subject: [PATCH] [FIX] auth_totp: Ignore email alert for API connections Description of the issue/behavior this commit addresses: When 2FA is on on a user and he tries to use an API key to do a xmlrpc request, the request fails. This is due to the system which choses whether or not to send an alert via mail to look in the request's values while there is actually no url request in that case. Desired behavior after this commit is merged: This commit adds a check to make sure a request is available before checking its values. opw-3645609 closes odoo/odoo#147475 Signed-off-by: Thomas Becquevort (thbe) --- addons/auth_totp/models/res_users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/auth_totp/models/res_users.py b/addons/auth_totp/models/res_users.py index 86202d9db2f..e97d1702963 100644 --- a/addons/auth_totp/models/res_users.py +++ b/addons/auth_totp/models/res_users.py @@ -48,7 +48,7 @@ class Users(models.Model): To be overriden if needs to be disabled for other 2FA providers """ - if self._mfa_type(): + if request and self._mfa_type(): key = request.httprequest.cookies.get('td_id') if key: if request.env['auth_totp.device']._check_credentials_for_uid(