e2e-improved
Some checks failed
Deploy on push / deploy (push) Failing after 7s

This commit is contained in:
2025-08-27 18:31:51 +03:00
parent e7cdcbc5dd
commit f3fc6c34ae
10 changed files with 170 additions and 88 deletions

View File

@@ -362,13 +362,31 @@ class AuthService:
if not author:
logger.warning(f"Пользователь {email} не найден")
return {"success": False, "token": None, "author": None, "error": "Пользователь не найден"}
user_roles = get_user_roles_in_community(int(author.id), community_id=1)
has_reader_role = "reader" in user_roles
# 🩵 Проверяем права с обработкой ошибок RBAC
is_admin_email = author.email in ADMIN_EMAILS.split(",")
has_reader_role = False
try:
user_roles = get_user_roles_in_community(int(author.id), community_id=1)
has_reader_role = "reader" in user_roles
logger.debug(f"Роли пользователя {email}: {user_roles}")
except Exception as rbac_error:
logger.warning(f"🧿 RBAC ошибка для {email}: {rbac_error}")
# Если RBAC не работает, разрешаем вход только админам
if not is_admin_email:
logger.warning(f"RBAC недоступен и {email} не админ - запрещаем вход")
return {
"success": False,
"token": None,
"author": None,
"error": "Система ролей временно недоступна. Попробуйте позже.",
}
logger.info(f"🔒 RBAC недоступен, но {email} - админ, разрешаем вход")
logger.debug(f"Роли пользователя {email}: {user_roles}")
if not has_reader_role and author.email not in ADMIN_EMAILS.split(","):
logger.warning(f"У пользователя {email} нет роли 'reader'. Текущие роли: {user_roles}")
# Проверяем права: админы или пользователи с ролью reader
if not has_reader_role and not is_admin_email:
logger.warning(f"У пользователя {email} нет роли 'reader' и он не админ")
return {
"success": False,
"token": None,