fix(server): add role aliases in roles.py to fix broken admin_router imports
This commit is contained in:
+2
-1
@@ -383,7 +383,8 @@ async def get_current_user(
|
|||||||
}
|
}
|
||||||
|
|
||||||
def require_role(min_role: int):
|
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)):
|
async def dependency(current_user: dict = Depends(get_current_user)):
|
||||||
if current_user["role"] < min_role:
|
if current_user["role"] < min_role:
|
||||||
from roles import ROLE_NAMES
|
from roles import ROLE_NAMES
|
||||||
|
|||||||
@@ -9,6 +9,19 @@ class UserRole(IntEnum):
|
|||||||
ELDER = 3 # Elder Moderator
|
ELDER = 3 # Elder Moderator
|
||||||
CREATOR = 4 # Создатель
|
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] = {
|
ROLE_NAMES: Dict[int, str] = {
|
||||||
UserRole.USER: "Игрок",
|
UserRole.USER: "Игрок",
|
||||||
UserRole.PASS_HOLDER: "Игрок [Проходка]",
|
UserRole.PASS_HOLDER: "Игрок [Проходка]",
|
||||||
|
|||||||
Reference in New Issue
Block a user