mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-21 03:19:52 +00:00
perf: Update confirmation backend definitions to use ConfirmType
This commit is contained in:
@@ -3,3 +3,4 @@ from .password import ConfirmPassword
|
||||
from .relogin import ConfirmReLogin
|
||||
|
||||
CONFIRM_BACKENDS = [ConfirmReLogin, ConfirmPassword, ConfirmMFA]
|
||||
CONFIRM_BACKEND_MAP = {backend.name: backend for backend in CONFIRM_BACKENDS}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
from users.models import User
|
||||
|
||||
from .base import BaseConfirm
|
||||
from ..const import ConfirmType
|
||||
|
||||
|
||||
class ConfirmMFA(BaseConfirm):
|
||||
name = 'mfa'
|
||||
display_name = 'MFA'
|
||||
name = ConfirmType.MFA.value
|
||||
display_name = ConfirmType.MFA.name
|
||||
|
||||
def check(self):
|
||||
return self.user.active_mfa_backends and self.user.mfa_enabled
|
||||
|
@@ -2,11 +2,12 @@ from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from authentication.mixins import authenticate
|
||||
from .base import BaseConfirm
|
||||
from ..const import ConfirmType
|
||||
|
||||
|
||||
class ConfirmPassword(BaseConfirm):
|
||||
name = 'password'
|
||||
display_name = _('Password')
|
||||
name = ConfirmType.PASSWORD.value
|
||||
display_name = ConfirmType.PASSWORD.name
|
||||
|
||||
def check(self):
|
||||
return self.user.is_password_authenticate()
|
||||
|
@@ -4,6 +4,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .base import BaseConfirm
|
||||
from ..const import ConfirmType
|
||||
|
||||
SPECIFIED_TIME = 5
|
||||
|
||||
@@ -11,8 +12,8 @@ RELOGIN_ERROR = _('Login time has exceeded {} minutes, please login again').form
|
||||
|
||||
|
||||
class ConfirmReLogin(BaseConfirm):
|
||||
name = 'relogin'
|
||||
display_name = 'Re-Login'
|
||||
name = ConfirmType.RELOGIN.value
|
||||
display_name = ConfirmType.RELOGIN.name
|
||||
|
||||
def check(self):
|
||||
return not self.user.is_password_authenticate()
|
||||
|
Reference in New Issue
Block a user