From 6f5300226664619774f24f5835722655b235f5da Mon Sep 17 00:00:00 2001 From: SashegDev Date: Mon, 4 May 2026 21:04:44 +0000 Subject: [PATCH] fix(server): add role aliases in roles.py to fix broken admin_router imports --- server/auth.py | 3 ++- server/roles.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/server/auth.py b/server/auth.py index c66c5ab..e2a2d10 100644 --- a/server/auth.py +++ b/server/auth.py @@ -383,7 +383,8 @@ async def get_current_user( } def require_role(min_role: int): - """Декоратор для проверки роли""" + """Dependency for checking minimum required role""" + from roles import UserRole async def dependency(current_user: dict = Depends(get_current_user)): if current_user["role"] < min_role: from roles import ROLE_NAMES diff --git a/server/roles.py b/server/roles.py index f71b834..d045275 100644 --- a/server/roles.py +++ b/server/roles.py @@ -9,6 +9,19 @@ class UserRole(IntEnum): ELDER = 3 # Elder Moderator CREATOR = 4 # Создатель +# Aliases for backwards compatibility with admin_router.py +ROLE_USER = UserRole.USER +ROLE_PASS_HOLDER = UserRole.PASS_HOLDER +ROLE_MODERATOR = UserRole.MODERATOR +ROLE_ELDER = UserRole.ELDER +ROLE_CREATOR = UserRole.CREATOR + +__all__ = [ + "UserRole", "ROLE_USER", "ROLE_PASS_HOLDER", "ROLE_MODERATOR", + "ROLE_ELDER", "ROLE_CREATOR", "ROLE_NAMES", "Permissions", + "ROLE_PERMISSIONS", "has_permission", "require_permission", +] + ROLE_NAMES: Dict[int, str] = { UserRole.USER: "Игрок", UserRole.PASS_HOLDER: "Игрок [Проходка]",