Skip to content

Commit

Permalink
fix: multilevel permissions in can() method
Browse files Browse the repository at this point in the history
refactor authorization checks to support nested permissions in can()
  • Loading branch information
bgeneto committed Nov 14, 2024
1 parent 8a77efd commit ec8b41e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Authorization/Traits/Authorizable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) !== [];
}

/**
Expand Down

0 comments on commit ec8b41e

Please sign in to comment.