Skip to content

Commit

Permalink
perf: update const import
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Dec 19, 2024
1 parent e983ac3 commit 2956f2e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions apps/authentication/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from users.models import User
from users.utils import LoginBlockUtil, MFABlockUtils, LoginIpBlockUtil
from . import errors
from .const import FACE_CONTEXT_CACHE_TTL, FACE_SESSION_KEY, FACE_CONTEXT_CACHE_KEY_PREFIX
from .signals import post_auth_success, post_auth_failed

logger = get_logger(__name__)
Expand Down Expand Up @@ -434,7 +435,6 @@ class AuthFaceMixin:

@staticmethod
def _get_face_cache_key(token):
from authentication.const import FACE_CONTEXT_CACHE_KEY_PREFIX
return f"{FACE_CONTEXT_CACHE_KEY_PREFIX}_{token}"

@staticmethod
Expand All @@ -457,13 +457,11 @@ def create_face_verify_context(self, data=None):
context_data.update(data)

cache_key = self._get_face_cache_key(token)
from .const import FACE_CONTEXT_CACHE_TTL, FACE_SESSION_KEY
cache.set(cache_key, context_data, FACE_CONTEXT_CACHE_TTL)
self.request.session[FACE_SESSION_KEY] = token
return token

def get_face_token_from_session(self):
from authentication.const import FACE_SESSION_KEY
token = self.request.session.get(FACE_SESSION_KEY)
if not token:
raise ValueError("Face recognition token is missing from the session.")
Expand Down Expand Up @@ -595,7 +593,8 @@ def clear_auth_mark(self):
keys = [
'auth_password', 'user_id', 'auth_confirm_required',
'auth_notice_required', 'auth_ticket_id', 'auth_acl_id',
'user_session_id', 'user_log_id', 'can_send_notifications'
'user_session_id', 'user_log_id', 'can_send_notifications',
'next',
]
for k in keys:
self.request.session.pop(k, '')
Expand Down

0 comments on commit 2956f2e

Please sign in to comment.