Keep delegated staff and service tickets within assigned roles

This commit is contained in:
parkel committed 2026-11-23 20:36:59 +01:00
1 parent 1933827a1c
commit 2d2cd1837e
2 files changed
+4 -5

No files matched your search

+1 -3
View File
@@ -31,9 +31,7 @@ def assigned_roles(user):
if not user.is_authenticated or not user.is_active: if not user.is_authenticated or not user.is_active:
return {} return {}
roles = {} roles = {}
if user.is_superuser or ( if user.is_superuser:
user.is_staff and user.has_perm("hosting.view_hostingaccount")
):
roles[PanelRole.ADMIN] = user.pk roles[PanelRole.ADMIN] = user.pk
customer = getattr(user, "hosting_customer", None) customer = getattr(user, "hosting_customer", None)
if customer is not None: if customer is not None:
+3 -2
View File
@@ -20,8 +20,9 @@ def issue_signon_grant(model, actor, **selection):
now = timezone.now() now = timezone.now()
model.objects.filter(expires_at__lte=now).delete() model.objects.filter(expires_at__lte=now).delete()
token = secrets.token_urlsafe(32) token = secrets.token_urlsafe(32)
role = getattr(actor, "panel_role", None) roles = assigned_roles(actor)
scope = [role, assigned_roles(actor).get(role)] if role else [] role = getattr(actor, "panel_role", None) or next(iter(roles), None)
scope = [role, roles.get(role)] if role else []
model.objects.create( model.objects.create(
token_digest=token_digest(token), token_digest=token_digest(token),
actor=actor, actor=actor,