fix: allow authorised fiscal maintenance by the same responsible person
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-21 12:39:07 +02:00
parent 226fd308dd
commit 4a4d121275
17 changed files with 615 additions and 39 deletions
+10 -1
View File
@@ -8,15 +8,24 @@ final class SimulationTaxGovernanceAccess
{
private const ROLES = ['editors', 'reviewers', 'approvers', 'publishers'];
public static function maintainer(User $user): bool
{
return $user->hasVerifiedEmail() && ! app(PortalProfileAccess::class)->has($user, 'auditor') && ($user->can('manage-portal')
|| app(ScopedPortalAdministration::class)->administrative($user));
}
public static function requireRole(User $user, string $role): void
{
abort_unless(in_array($role, self::ROLES, true), 500, 'Função de governação desconhecida.');
abort_unless(in_array(strtolower($user->email), config('simulation-tax-governance.'.$role, []), true),
abort_unless(self::maintainer($user) || in_array(strtolower($user->email), config('simulation-tax-governance.'.$role, []), true),
403, 'O utilizador não está designado para esta função de governação fiscal.');
}
public static function requireAnyRole(User $user): void
{
if (self::maintainer($user)) {
return;
}
foreach (self::ROLES as $role) {
if (in_array(strtolower($user->email), config('simulation-tax-governance.'.$role, []), true)) {
return;