fix(server): add role aliases in roles.py to fix broken admin_router imports

This commit is contained in:
SashegDev
2026-05-04 21:04:44 +00:00
parent 9688509df5
commit 6f53002266
2 changed files with 15 additions and 1 deletions
+2 -1
View File
@@ -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
+13
View File
@@ -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: "Игрок [Проходка]",