17 lines
461 B
Python
17 lines
461 B
Python
from __future__ import annotations
|
|
|
|
from app.core.constants import Role
|
|
|
|
|
|
def is_admin(role: str) -> bool:
|
|
return role in Role.ADMIN_ROLES
|
|
|
|
|
|
def is_management(role: str) -> bool:
|
|
return role in Role.MANAGEMENT_ROLES
|
|
|
|
|
|
def can_manage_user(actor_role: str, target_role: str) -> bool:
|
|
hierarchy = {Role.SUPERADMIN: 4, Role.ADMIN: 3, Role.MANAGER: 2, Role.USER: 1, Role.DEVICE: 0}
|
|
return hierarchy.get(actor_role, 0) > hierarchy.get(target_role, 0)
|