[FIX] auth_totp_mail_enforce: friendlier error message
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) <dle@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user