core/auth/state.py
Untone 1d64811880
All checks were successful
Deploy on push / deploy (push) Successful in 6s
userlist-demo-ready
2025-05-20 00:00:24 +03:00

22 lines
717 B
Python
Raw 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):
self.logged_in = False
self.author_id = None
self.token = None
self.username = None
self.is_admin = False
self.is_editor = False
self.error = None
def __bool__(self):
"""Возвращает True если пользователь авторизован"""
return self.logged_in