perf: 修复首页登录mfa错误提示

This commit is contained in:
ibuler
2021-11-15 18:36:22 +08:00
committed by 老广
parent 22c9dfc0f2
commit cc2d47e6dc
11 changed files with 113 additions and 91 deletions

View File

@@ -312,10 +312,13 @@ class MFAMixin:
ok = False
mfa_backend = user.get_mfa_backend_by_type(mfa_type)
if mfa_backend:
ok, msg = mfa_backend.check_code(code)
backend_error = _('The MFA type ({}) is not enabled')
if not mfa_backend:
msg = backend_error.format(mfa_type)
elif not mfa_backend.is_active():
msg = backend_error.format(mfa_backend.display_name)
else:
msg = _('The MFA type({}) is not supported'.format(mfa_type))
ok, msg = mfa_backend.check_code(code)
if ok:
self.mark_mfa_ok(mfa_type)