- 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.
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace classes;
|
|
|
|
use modules\subusers\helpers\subusers_permission_node_key;
|
|
|
|
/**
|
|
* Lightweight DTO that links a classic string permission to an optional
|
|
* Subusers permission node key. Used by routes to declare permissions
|
|
* that can be satisfied by either the main user permission system or
|
|
* a subuser's granted permission node, depending on who is authenticated.
|
|
*/
|
|
class permission_node
|
|
{
|
|
/**
|
|
* The classic user permission string (e.g. "modules_motorapi_lookup")
|
|
*/
|
|
public string $permission;
|
|
|
|
/**
|
|
* Optional subusers node key that mirrors this permission for subusers
|
|
*/
|
|
public ?subusers_permission_node_key $subusers_node_key;
|
|
|
|
public function __construct(string $permission, ?subusers_permission_node_key $subusers_node_key = null)
|
|
{
|
|
$this->permission = $permission;
|
|
$this->subusers_node_key = $subusers_node_key;
|
|
}
|
|
|
|
public static function create(string $permission, ?subusers_permission_node_key $subusers_node_key = null): self
|
|
{
|
|
return new self($permission, $subusers_node_key);
|
|
}
|
|
}
|