Skip to content

Commit

Permalink
Add key and values to arrayAll function.
Browse files Browse the repository at this point in the history
  • Loading branch information
EarthlingDavey committed Nov 27, 2024
1 parent ae55af9 commit 9fea703
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions public/app/mu-plugins/moj-auth/traits/jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public function setJwt(object $args = new \stdClass()): array
*/
public function verifyJwtRoles(array $jwt_roles): bool
{

$this->log('verifyJwtRoles()');

if (!is_array($jwt_roles)) {
Expand Down Expand Up @@ -169,15 +168,15 @@ public function verifyJwtRoles(array $jwt_roles): bool
return false;
}

return $this->arrayAll($conditions, function ($condition, $key) {
$method = 'verifyJwtRole' . ucfirst($key);
return $this->arrayAll($conditions, function ($condition_name, $condition_value) {
$method = 'verifyJwtRole' . ucfirst($condition_name);

if (!method_exists($this, $method)) {
$this->log('verifyJwtRoles() $method does not exist.', null, 'error');
return false;
}

return $this->$method($condition);
return $this->$method($condition_value);
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions public/app/mu-plugins/moj-auth/traits/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public function arrayAny($array, $callback)

public function arrayAll($array, $callback)
{
foreach ($array as $entry) {
if (call_user_func($callback, $entry) === false)
foreach ($array as $key => $value) {
if (call_user_func($callback, $key, $value) === false)
return false;
}
return true;
Expand Down

0 comments on commit 9fea703

Please sign in to comment.