Switch panel roles with server-enforced account scope

This commit is contained in:
parkel committed 2026-11-23 20:28:22 +01:00
1 parent c4db2ec55f
commit 1933827a1c
16 files changed
+497 -15

No files matched your search

+15
View File
@@ -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