From 2cb7ad2da892eb36c1cf021a6a8aacde588999af Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 10 Oct 2018 00:27:11 +0200 Subject: [PATCH] app/library/Acl.php: in isAllowed() implement wildcard for controllers in modules. --- app/library/Acl.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/library/Acl.php b/app/library/Acl.php index 80a3157..b7814b7 100644 --- a/app/library/Acl.php +++ b/app/library/Acl.php @@ -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; }