Skip to content

Commit c0268d9

Browse files
move $matrix outside foreach loop
1 parent 60f1ae3 commit c0268d9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Authorization/Traits/Authorizable.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ public function can(string ...$permissions): bool
250250
// Check the groups the user belongs to
251251
$this->populateGroups();
252252

253+
// Get the group matrix
254+
$matrix = setting('AuthGroups.matrix');
255+
253256
foreach ($permissions as $permission) {
254257
// Permission must contain a scope and action
255258
if (strpos($permission, '.') === false) {
@@ -270,8 +273,6 @@ public function can(string ...$permissions): bool
270273
return false;
271274
}
272275

273-
$matrix = setting('AuthGroups.matrix');
274-
275276
foreach ($this->groupCache as $group) {
276277
// Check exact match
277278
if (isset($matrix[$group]) && in_array($permission, $matrix[$group], true)) {

0 commit comments

Comments
 (0)