Skip to content

Commit

Permalink
Applied code suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyskills committed Aug 18, 2023
1 parent eb50f85 commit acbeb07
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Authorization/Traits/Authorizable.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ public function hasPermission(string $permission): bool
*/
public function can(string ...$permissions): bool
{
// Get user's permissions and store in cache
$this->populatePermissions();

// Check the groups the user belongs to
$this->populateGroups();

foreach ($permissions as $permission) {
// Permission must contain a scope and action
if (strpos($permission, '.') === false) {
Expand All @@ -242,18 +248,13 @@ public function can(string ...$permissions): bool
);
}

$this->populatePermissions();

$permission = strtolower($permission);

// Check user's permissions
if (in_array($permission, $this->permissionsCache, true)) {
return true;
}

// Check the groups the user belongs to
$this->populateGroups();

if (! count($this->groupCache)) {
return false;
}
Expand Down

0 comments on commit acbeb07

Please sign in to comment.