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):