public function beforeExecuteRoute($dispatcher) { $action = $dispatcher->getActionName(); $controller = $dispatcher->getControllerName(); if (\Models\Users::isAuthorized()) { foreach (\Models\Users::getInstance()->getGroups() as $group) { if (static::getInstanceAccess()->isAllowed($group->getName(), $controller, $action) == \Phalcon\Acl::ALLOW) { return true; } } $this->forward('errors/Forbidden'); } else { if (static::getInstanceAccess()->isAllowed('guest', $controller, $action) == \Phalcon\Acl::ALLOW) { return true; } $this->redirect('/login/'); } return true; }