fix: Optimize UserConfirmDialog to send code via email (#15164)

* fix: Optimize UserConfirmDialog to send code via email

* fix: Optimize verification failure without error reporting

---------

Co-authored-by: halo <wuyihuangw@gmail.com>
Co-authored-by: Bryan <jiangjie.bai@fit2cloud.com>
This commit is contained in:
fit2bot
2025-04-08 15:50:15 +08:00
committed by GitHub
parent 519ec65ad4
commit 29ddfcac17
3 changed files with 19 additions and 21 deletions

View File

@@ -6,20 +6,25 @@ from common.utils import random_string
from common.utils.verify_code import SendAndVerifyCodeUtil
from settings.utils import get_login_title
from .base import BaseMFA
from ..const import MFAType
email_failed_msg = _("Email verify code invalid")
class MFAEmail(BaseMFA):
name = 'email'
display_name = _('Email')
name = MFAType.Email.value
display_name = MFAType.Email.name
placeholder = _('Email verification code')
def _check_code(self, code):
assert self.is_authenticated()
sender_util = SendAndVerifyCodeUtil(self.user.email, backend=self.name)
ok = sender_util.verify(code)
msg = '' if ok else email_failed_msg
ok = False
msg = ''
try:
ok = sender_util.verify(code)
except Exception as e:
msg = str(e)
return ok, msg
def is_active(self):