I'm trying to setup ACL, and it works find.
But now i have a problem, becuase I use folders in my controllers to have more structer. It's all setup as a namespace like this:
Controllers\admin\index Controllers\frontpage\index
But if I set index to private, the index in frontpage AND admin is effected.. I only need admin.. I use Vokuro
This is my code:
Inside my ACL ( Just whats important )
private $privateResources = array(
'index' => array(
'index'
)
);
And in my ControllerBase
$controllerName = $dispatcher->getControllerName();
$this->acl->rebuild();
// Only check permissions on private controllers
if ($this->acl->isPrivate($controllerName)) {
// Get the current identity
$identity = $this->auth->getIdentity();
// If there is no identity available the user is redirected to index/index
if (!is_array($identity)) {
$this->view->disable();
echo 'No access.';
return false;
}
// Check if the user have permission to the current option
$actionName = $dispatcher->getActionName();
if (!$this->acl->isAllowed($identity['rank'], $controllerName, $actionName)) {
$this->flash->notice('You don\'t have access to this module: ' . $controllerName . ':' . $actionName);
if ($this->acl->isAllowed($identity['rank'], $controllerName, 'index')) {
$dispatcher->forward(array(
'controller' => $controllerName,
'action' => 'index'
));
} else {
$this->view->disable();
$dispatcher->forward(array(
'controller' => 'index',
'action' => 'index'
));
}
return false;
}
}
I know that this is alot of code, but I hope someone got the answer for me, thanks!