From 98e9ab299bc38eadc4326f0cb4b6e1ae3ec44026 Mon Sep 17 00:00:00 2001 From: nda Date: Wed, 6 Dec 2023 10:11:22 -0400 Subject: [PATCH] [FIX] auth_totp_mail_enforce: friendlier error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit steps to reproduce: - install the module "2FA by mail" (auth_totp_mail_enforce) - open settings (this should bring the settings of the settings app) - activate "Two-factor authentification enforcing policy" to "Employees only" (or "All users") and save - try to (re)connect with a user (demo/demo or admin/admin)  before this commit: - internal server error after this commit: - error is passed to the user, allowing him (or the admin) to debug without contacting odoo support opw-3624816 closes odoo/odoo#147196 X-original-commit: a449210cc18f64460096cb43b3633d4861120d0e Signed-off-by: Denis Ledoux (dle) --- addons/auth_totp_mail_enforce/controllers/home.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/auth_totp_mail_enforce/controllers/home.py b/addons/auth_totp_mail_enforce/controllers/home.py index 64f19470029..795199da175 100644 --- a/addons/auth_totp_mail_enforce/controllers/home.py +++ b/addons/auth_totp_mail_enforce/controllers/home.py @@ -1,10 +1,13 @@ # -*- coding: utf-8 -*- +import logging import odoo.addons.auth_totp.controllers.home from odoo import http from odoo.exceptions import AccessDenied, UserError from odoo.http import request +_logger = logging.getLogger(__name__) + class Home(odoo.addons.auth_totp.controllers.home.Home): @http.route() @@ -22,5 +25,7 @@ class Home(odoo.addons.auth_totp.controllers.home.Home): response.qcontext['user']._send_totp_mail_code() except (AccessDenied, UserError) as e: response.qcontext['error'] = str(e) - + except Exception as e: + _logger.exception('Unable to send TOTP email') + response.qcontext['error'] = str(e) return response