25 lines
541 B
Python
25 lines
541 B
Python
ROLE_ADMIN = "admin"
|
|
ROLE_LEGAL = "legal"
|
|
ROLE_BUSINESS = "business"
|
|
ROLE_MEMBER = "member"
|
|
|
|
SUPPORTED_USER_ROLES = {
|
|
ROLE_ADMIN,
|
|
ROLE_LEGAL,
|
|
ROLE_BUSINESS,
|
|
ROLE_MEMBER,
|
|
}
|
|
|
|
DEFAULT_SELF_REGISTER_ROLE = ROLE_BUSINESS
|
|
|
|
|
|
def normalize_user_role(role: str) -> str:
|
|
normalized_role = role.strip().lower()
|
|
if normalized_role not in SUPPORTED_USER_ROLES:
|
|
raise ValueError("invalid role")
|
|
return normalized_role
|
|
|
|
|
|
def is_admin_role(role: str | None) -> bool:
|
|
return (role or "").strip().lower() == ROLE_ADMIN
|