fix: remove author creation from auth decorators
Some checks failed
Deploy on push / deploy (push) Failing after 7s

- Убрал логику создания Author объектов в декораторах login_required и login_accepted
- Это исправляет ошибку 'Cannot return null for non-nullable field Author.slug'
- Авторы должны создаваться только в резолверах при необходимости
This commit is contained in:
2025-08-12 12:37:34 +03:00
parent d823b925d8
commit 503bbc17dd

View File

@@ -758,16 +758,6 @@ class AuthService:
if token: if token:
info.context["token"] = token info.context["token"] = token
# Получаем автора если его нет в контексте
if not info.context.get("author") or not isinstance(info.context["author"], dict):
# Поздний импорт для избежания циклических зависимостей
from cache.cache import get_cached_author_by_id
author = await get_cached_author_by_id(int(user_id), lambda x: x)
if not author:
logger.error(f"Профиль автора не найден для пользователя {user_id}")
info.context["author"] = author
return await f(*args, **kwargs) return await f(*args, **kwargs)
return decorated_function return decorated_function
@@ -788,19 +778,11 @@ class AuthService:
info.context["roles"] = user_roles info.context["roles"] = user_roles
info.context["is_admin"] = is_admin info.context["is_admin"] = is_admin
# Поздний импорт для избежания циклических зависимостей # Автор будет получен в резолвере при необходимости
from cache.cache import get_cached_author_by_id pass
author = await get_cached_author_by_id(int(user_id), lambda x: x)
if author:
is_owner = True
info.context["author"] = author.dict(is_owner or is_admin)
else:
logger.error(f"login_accepted: Профиль автора не найден для пользователя {user_id}")
else: else:
logger.debug("login_accepted: Пользователь не авторизован") logger.debug("login_accepted: Пользователь не авторизован")
info.context["roles"] = None info.context["roles"] = None
info.context["author"] = None
info.context["is_admin"] = False info.context["is_admin"] = False
return await f(*args, **kwargs) return await f(*args, **kwargs)