From ec8b41ed4f278604e11482eac3d2a5c9012556c9 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Thu, 14 Nov 2024 01:25:55 -0300 Subject: [PATCH] fix: multilevel permissions in can() method refactor authorization checks to support nested permissions in can() --- src/Authorization/Traits/Authorizable.php | 2 +- src/Entities/Group.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Authorization/Traits/Authorizable.php b/src/Authorization/Traits/Authorizable.php index d49628641..72fd527a3 100644 --- a/src/Authorization/Traits/Authorizable.php +++ b/src/Authorization/Traits/Authorizable.php @@ -287,7 +287,7 @@ public function can(string ...$permissions): bool $check = implode('.', array_slice($parts, 0, $i)) . '.*'; $checks[] = $check; } - if (isset($matrix[$group]) && array_intersect($checks, $matrix[$group])) { + if (isset($matrix[$group]) && array_intersect($checks, $matrix[$group]) !== []) { return true; } } diff --git a/src/Entities/Group.php b/src/Entities/Group.php index 93e06be79..5b417a6b2 100644 --- a/src/Entities/Group.php +++ b/src/Entities/Group.php @@ -95,7 +95,7 @@ public function can(string $permission): bool return $this->permissions !== null && $this->permissions !== [] - && ! empty(array_intersect($checks, $this->permissions)); + && array_intersect($checks, $this->permissions) !== []; } /**