초기 커밋
This commit is contained in:
16
app/core/permissions.py
Normal file
16
app/core/permissions.py
Normal file
@@ -0,0 +1,16 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user