Files
core/auth/state.py
Untone 9a2b792f08
Some checks failed
Deploy on push / deploy (push) Failing after 6s
refactored
2025-08-17 17:56:31 +03:00

24 lines
792 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Классы состояния авторизации
"""
class AuthState:
"""
Класс для хранения информации о состоянии авторизации пользователя.
Используется в аутентификационных middleware и функциях.
"""
def __init__(self) -> None:
self.logged_in: bool = False
self.author_id: str | None = None
self.token: str | None = None
self.username: str | None = None
self.is_admin: bool = False
self.is_editor: bool = False
self.error: str | None = None
def __bool__(self) -> bool:
"""Возвращает True если пользователь авторизован"""
return self.logged_in