Switch panel roles with server-enforced account scope
This commit is contained in:
1 parent
c4db2ec55f
commit
1933827a1c
16 files changed
+497
-15
No files matched your search
@@ -1,3 +1,12 @@
|
||||
from enum import StrEnum
|
||||
|
||||
|
||||
class PanelRole(StrEnum):
|
||||
ADMIN = "administrator"
|
||||
MANAGER = "manager"
|
||||
CUSTOMER = "customer"
|
||||
|
||||
|
||||
NAVIGATION_SECTIONS = {
|
||||
"accounts": "accounts",
|
||||
"retired-accounts": "accounts",
|
||||
@@ -14,12 +23,18 @@ NAVIGATION_SECTIONS = {
|
||||
|
||||
|
||||
def customer_for_user(user):
|
||||
role = getattr(user, "panel_role", None)
|
||||
if role is not None and role != PanelRole.CUSTOMER:
|
||||
return None
|
||||
if not user.is_authenticated or user.is_superuser:
|
||||
return None
|
||||
return getattr(user, "hosting_customer", None)
|
||||
|
||||
|
||||
def reseller_for_user(user):
|
||||
role = getattr(user, "panel_role", None)
|
||||
if role is not None and role != PanelRole.MANAGER:
|
||||
return None
|
||||
if (
|
||||
not user.is_authenticated
|
||||
or user.is_superuser
|
||||
|
||||
Reference in new issue
Block a user