Roles
This commit is contained in:
@@ -27,6 +27,24 @@ class UserRole(str, enum.Enum):
|
||||
CLIENT_ADMIN = "CLIENT_ADMIN" # Admin de organización cliente
|
||||
CLIENT_USER = "CLIENT_USER" # Usuario final cliente
|
||||
|
||||
@property
|
||||
def is_global(self) -> bool:
|
||||
"""True si el rol tiene alcance global (staff interno cross-tenant)."""
|
||||
return self in (
|
||||
UserRole.ADMIN,
|
||||
UserRole.SUPPORT_MANAGER,
|
||||
UserRole.AGENT,
|
||||
UserRole.AUDITOR,
|
||||
)
|
||||
|
||||
@property
|
||||
def is_client(self) -> bool:
|
||||
"""True si el rol está acotado al tenant del usuario."""
|
||||
return self in (
|
||||
UserRole.CLIENT_ADMIN,
|
||||
UserRole.CLIENT_USER,
|
||||
)
|
||||
|
||||
|
||||
class User(Base):
|
||||
"""Modelo de Usuario."""
|
||||
@@ -113,11 +131,8 @@ class User(Base):
|
||||
|
||||
@property
|
||||
def is_client(self) -> bool:
|
||||
"""Check if user is a client."""
|
||||
return self.role in [
|
||||
UserRole.CLIENT_ADMIN,
|
||||
UserRole.CLIENT_USER
|
||||
]
|
||||
"""Check if user is a client (rol acotado al propio tenant)."""
|
||||
return self.role.is_client
|
||||
|
||||
@property
|
||||
def can_manage_users(self) -> bool:
|
||||
@@ -125,7 +140,7 @@ class User(Base):
|
||||
return self.role in [
|
||||
UserRole.ADMIN,
|
||||
UserRole.SUPPORT_MANAGER,
|
||||
UserRole.CLIENT_ADMIN
|
||||
UserRole.CLIENT_ADMIN,
|
||||
]
|
||||
|
||||
@property
|
||||
@@ -134,7 +149,7 @@ class User(Base):
|
||||
return self.role in [
|
||||
UserRole.ADMIN,
|
||||
UserRole.SUPPORT_MANAGER,
|
||||
UserRole.AGENT
|
||||
UserRole.AGENT,
|
||||
]
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user