From 58a10778cd94d6e4bdb02163cefc2d33c0439e68 Mon Sep 17 00:00:00 2001 From: xinwen Date: Fri, 10 Sep 2021 14:39:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/errors.py | 2 +- apps/authentication/sms_verify_code.py | 11 +++-- .../templates/authentication/login_otp.html | 42 ++++++++++++++----- apps/authentication/views/mfa.py | 2 +- apps/locale/zh/LC_MESSAGES/django.po | 35 +++++++++++----- 5 files changed, 65 insertions(+), 27 deletions(-) diff --git a/apps/authentication/errors.py b/apps/authentication/errors.py index c8005ba95..f2346ab6d 100644 --- a/apps/authentication/errors.py +++ b/apps/authentication/errors.py @@ -71,7 +71,7 @@ sms_failed_msg = _( "(The account will be temporarily locked for {block_time} minutes)" ) mfa_type_failed_msg = _( - "The MFA type({mfa_type}) is not supported" + "The MFA type({mfa_type}) is not supported, " "You can also try {times_try} times " "(The account will be temporarily locked for {block_time} minutes)" ) diff --git a/apps/authentication/sms_verify_code.py b/apps/authentication/sms_verify_code.py index 33d17b207..0c3e986ce 100644 --- a/apps/authentication/sms_verify_code.py +++ b/apps/authentication/sms_verify_code.py @@ -52,10 +52,13 @@ class VerifyCodeUtil: ttl = self.ttl() if ttl > 0: raise CodeSendTooFrequently(ttl) - - self.generate() - self.save() - self.send() + try: + self.generate() + self.save() + self.send() + except JMSException: + self.clear() + raise def generate(self): code = ''.join(random.sample('0123456789', 4)) diff --git a/apps/authentication/templates/authentication/login_otp.html b/apps/authentication/templates/authentication/login_otp.html index 858c2737d..ff4d4e28b 100644 --- a/apps/authentication/templates/authentication/login_otp.html +++ b/apps/authentication/templates/authentication/login_otp.html @@ -19,19 +19,25 @@ {% endfor %} -
- - - {% trans 'Please enter the verification code' %} - -
- - +
+ + + +
+ +
{% trans "Can't provide security? Please contact the administrator!" %}
+