Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #122 from arekkas/120-fix
Browse files Browse the repository at this point in the history
Fixes #120
  • Loading branch information
bakura10 committed Dec 14, 2013
2 parents 4cdea96 + 8bb00e7 commit 05f9bf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ZfcRbac/Service/AuthorizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ public function isGranted($permission, $assertion = null)
if (null !== $assertion) {
$identity = $this->identityProvider->getIdentity();

if (is_callable($assertion) && !$assertion($identity)) {
return false;
} elseif ($assertion instanceof AssertionInterface && !$assertion->assert($identity)) {
return false;
if (is_callable($assertion)) {
if (!$assertion($identity)) {
return false;
}
} elseif ($assertion instanceof AssertionInterface) {
if (!$assertion->assert($identity)) {
return false;
}
} else {
throw new Exception\InvalidArgumentException(sprintf(
'Assertions must be callable or implement ZfcRbac\Assertion\AssertionInterface, "%s" given',
Expand Down
8 changes: 8 additions & 0 deletions tests/ZfcRbacTest/Service/AuthorizationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ function() { return false; },
false
],

// Simple is accepted from dynamic assertion
[
'member',
'read',
function() { return true; },
true
],

// Simple is refused from no role
[
[],
Expand Down

0 comments on commit 05f9bf7

Please sign in to comment.