Skip to content

Commit

Permalink
#47 fix callable plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
steinkel committed Aug 1, 2019
1 parent 0150783 commit fe61086
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rbac/Rbac.php
Expand Up @@ -171,7 +171,7 @@ protected function _matchPermission(array $permission, array $user, $role, Serve
$key = ltrim($key, '*');
}

if (is_callable($value)) {
if (!is_string($value) && is_callable($value)) {
$return = (bool)call_user_func($value, $user, $role, $request);
} elseif ($value instanceof Rule) {
$return = (bool)$value->allowed($user, $role, $request);
Expand Down
23 changes: 23 additions & 0 deletions tests/TestCase/Rbac/RbacTest.php
Expand Up @@ -1099,6 +1099,29 @@ function () {
//expected
false,
],
'plugin-name-matches-callable-function' => [
//permissions
[[
'plugin' => 'Ord',
'controller' => 'Tests',
'action' => 'test',
'role' => 'admin',
]],
//user
[
'id' => 1,
'username' => 'luke',
'role' => 'admin',
],
//request
[
'plugin' => 'Ord',
'controller' => 'Tests',
'action' => 'test'
],
//expected
true,
],
];
}

Expand Down

0 comments on commit fe61086

Please sign in to comment.