Добавлен класс ExpiredTokenAuthentication
This commit is contained in:
@@ -7,3 +7,5 @@
|
||||
"""
|
||||
Классов авторизации
|
||||
"""
|
||||
|
||||
from .expiring_token_authentication import ExpiringTokenAuthentication
|
||||
|
||||
@@ -13,6 +13,7 @@ from typing import Any
|
||||
from rest_framework.authentication import TokenAuthentication
|
||||
from rest_framework.request import Request
|
||||
|
||||
from net.xeaf.rack.managers import AccountManager
|
||||
from net.xeaf.rack.managers import LocaleManager
|
||||
from net.xeaf.rack.managers import SessionManager
|
||||
from net.xeaf.rack.models import AccountModel
|
||||
@@ -54,8 +55,21 @@ class ExpiringTokenAuthentication(TokenAuthentication):
|
||||
return None, None
|
||||
|
||||
account = session.account
|
||||
if not account.is_active or account.is_deleted():
|
||||
if not self._check_account(account):
|
||||
return None, None
|
||||
|
||||
SessionManager.renew_session(session)
|
||||
return session.account, session
|
||||
|
||||
@classmethod
|
||||
def _check_account(cls, account: AccountModel) -> bool:
|
||||
"""
|
||||
Проверка учетной записи
|
||||
|
||||
:param account: Учетная запись
|
||||
"""
|
||||
|
||||
# Можно прошедшим проверку и не удаленным
|
||||
reject = AccountManager.check_account_auth(account)
|
||||
result = reject is None and not account.is_deleted()
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user