From 5e177b6ce5e5183fb6a136ae76a7ff6398fd531f Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 25 May 2023 18:21:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=AE=A4=E8=AF=81=20MFA=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=B6=E6=B2=A1=E6=9C=89=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=85=B7=E4=BD=93=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E7=9A=84?= =?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/backends/custom.py | 1 + apps/authentication/errors/failed.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/authentication/backends/custom.py b/apps/authentication/backends/custom.py index c98d1742c..d05e097d5 100644 --- a/apps/authentication/backends/custom.py +++ b/apps/authentication/backends/custom.py @@ -1,5 +1,6 @@ from django.conf import settings from django.utils.module_loading import import_string +from django.utils.translation import ugettext_lazy as _ from common.utils import get_logger from django.contrib.auth import get_user_model from authentication.signals import user_auth_failed, user_auth_success diff --git a/apps/authentication/errors/failed.py b/apps/authentication/errors/failed.py index c85695fe5..3e0848524 100644 --- a/apps/authentication/errors/failed.py +++ b/apps/authentication/errors/failed.py @@ -89,8 +89,6 @@ class MFAFailedError(AuthFailedNeedLogMixin, AuthFailedError): msg: str def __init__(self, username, request, ip, mfa_type, error): - super().__init__(username=username, request=request) - util = MFABlockUtils(username, ip) times_remainder = util.incr_failed_count() block_time = settings.SECURITY_LOGIN_LIMIT_TIME @@ -101,6 +99,7 @@ class MFAFailedError(AuthFailedNeedLogMixin, AuthFailedError): ) else: self.msg = const.block_mfa_msg.format(settings.SECURITY_LOGIN_LIMIT_TIME) + super().__init__(username=username, request=request) class BlockMFAError(AuthFailedNeedLogMixin, AuthFailedError):