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

@@ -10,6 +10,7 @@ otp_failed_msg = _("OTP code invalid, or server time error")
class MFAOtp(BaseMFA):
name = 'otp'
display_name = _('OTP')
placeholder = _('OTP verification code')
def check_code(self, code):
from users.utils import check_otp_code

View File

@@ -9,7 +9,8 @@ mfa_failed_msg = _("Radius verify code invalid")
class MFARadius(BaseMFA):
name = 'otp_radius'
display_name = _('Radius MFA')
display_name = 'Radius'
placeholder = _("Radius verification code")
def check_code(self, code):
assert self.is_authenticated()

View File

@@ -19,8 +19,12 @@ class MFASms(BaseMFA):
def check_code(self, code):
assert self.is_authenticated()
ok = self.sms.verify(code)
msg = '' if ok else sms_failed_msg
ok = False
msg = ''
try:
ok = self.sms.verify(code)
except Exception as e:
msg = str(e)
return ok, msg
def is_active(self):