ZF-Commons / zfc-rbac

Role-based access control module to provide additional features on top of Zend\Permissions\Rbac
BSD 3-Clause "New" or "Revised" License
181 stars 111 forks source link

Change/pass permission as param to assertions #344

Closed basz closed 8 years ago

basz commented 8 years ago

As proposed this PR passes the requested permission name to the Assertion::assert method, so the assertion can assert based on that information.

Note: based on an PR #342 that is also a proposal. To avoid merge conflicts please review/merge that one first.

basz commented 8 years ago

/cc @prolic

danizord commented 8 years ago

LGFM :+1:

prolic commented 8 years ago

I don't see a use-case. Can someone explain it to me?

basz commented 8 years ago
public function assert($permission, IdentityInterface $identity = null, $context = null): bool {
    if ((string) $identity->getUserId() === (string) $context->userId()) {
        return true;
    }

    return $this->authorizationService->isGranted($identity, sprint("%s.forOthers", $permission, $context));
}
prolic commented 8 years ago

ok, good for me then! :+1:

basz commented 8 years ago

rebased