Integrate subuser permission node system and refactor route-level permissions

- Add `permission_node` DTO to link classic permissions with subuser-specific nodes.
- Extend `authentication` to support subuser resolution via tokens.
- Introduce route traits for permission evaluation with subuser context.
- Update `requirePermission` and `hasPermission` to handle subuser grants dynamically.
- Implement fallback mechanisms for customer number context in subuser permissions.
This commit is contained in:
Jeppe Bundgaard
2026-02-12 13:54:28 +01:00
parent 2159cd293c
commit d26b94de3b
4 changed files with 189 additions and 18 deletions
@@ -56,4 +56,27 @@ class subuser_user_grant implements subusers_user_grant_i
}
}
}
/**
* Check if a specific permission node is granted for this subuser/customer pair
*/
public function hasNode(\modules\subusers\helpers\subusers_permission_node_key $key): bool
{
$reflection = new \ReflectionClass($this);
$properties = $reflection->getProperties();
foreach ($properties as $property) {
$propertyType = $property->getType();
if ($propertyType && is_a($propertyType->getName(), subusers_permission_nodes::class, true)) {
$permissionNodes = $property->getValue($this);
if (is_array($permissionNodes)) {
foreach ($permissionNodes as $node) {
if ($node->nodeKey->name === $key->name) {
return (bool)($node->value === true);
}
}
}
}
}
return false;
}
}