public function beforeExecuteRoute(Event $event, Micro $app) { $role = $this->authManager->loggedIn() ? self::ROLE_PRIVATE : self::ROLE_PUBLIC; // Get the current resource/endpoint from the micro app $endpoint = $app->getRouter()->getMatchedRoute()->getPattern(); // Get the access control list $acl = $this->_getAcl(); // See if they have permission $allowed = $acl->isAllowed($role, self::RESOURCE_API, $endpoint); if ($allowed != \Phalcon\Acl::ALLOW) { if ($this->authManager->loggedIn()) { throw new UserException(ErrorCodes::AUTH_FORBIDDEN); } else { throw new UserException(ErrorCodes::AUTH_UNAUTHORIZED); } } }
public function getRouter() { $router = parent::getRouter(); $router->setUriSource($router::URI_SOURCE_SERVER_REQUEST_URI); return $router; }