Skip to content

Commit acbeb07

Browse files
committed
Applied code suggestions
1 parent eb50f85 commit acbeb07

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Authorization/Traits/Authorizable.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ public function hasPermission(string $permission): bool
233233
*/
234234
public function can(string ...$permissions): bool
235235
{
236+
// Get user's permissions and store in cache
237+
$this->populatePermissions();
238+
239+
// Check the groups the user belongs to
240+
$this->populateGroups();
241+
236242
foreach ($permissions as $permission) {
237243
// Permission must contain a scope and action
238244
if (strpos($permission, '.') === false) {
@@ -242,18 +248,13 @@ public function can(string ...$permissions): bool
242248
);
243249
}
244250

245-
$this->populatePermissions();
246-
247251
$permission = strtolower($permission);
248252

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

254-
// Check the groups the user belongs to
255-
$this->populateGroups();
256-
257258
if (! count($this->groupCache)) {
258259
return false;
259260
}

0 commit comments

Comments
 (0)