Archived
1
0
Fork 0

app/library/Acl.php: in isAllowed() implement wildcard for controllers in modules.

This commit is contained in:
Henrik Hautakoski 2018-10-10 00:27:11 +02:00
parent c94c0fed7b
commit 2cb7ad2da8
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -33,6 +33,19 @@ class Acl
*/
public function isAllowed($role, $resource)
{
// Special stuff here :) for resources within modules.
// Modules and controllers are separated by "/"
$pos = strpos($resource, '/');
if ($pos !== false) {
// Construct the wildcard resource.
$wildcard = substr($resource, 0, $pos+1) . '*';
// If we have this wildcard resource, check against that instead.
if ($this->hasResource($wildcard)) {
$resource = $wildcard;
}
}
return $this->_adapter->isAllowed($role, $resource, 'All') == \Phalcon\Acl::ALLOW;
}