public function indexAction() { $model = new ViewModel(); $this->layout('layout/adminblank'); $model->setTemplate('core/index'); $auth = new Auth('Config', 'Session', 'Auth_Admin'); $auth->getAuthStorage()->clear(); return $this->redirect()->toUrl('/admin/'); }
public function authority($e) { $router = $e->getRouteMatch(); $moduleNamespace = $router->getParam('moduleNamespace'); if ($moduleNamespace != 'admin') { return false; } $controller = $router->getParam('controllerName'); $action = $router->getParam('action'); //No authority pages : login form | login post | logout //TODO : add no authority page to config file if ($controller == 'core' && $action == 'index' || $controller == 'logout' && $action == 'index' || $controller == 'login' && ($action = 'index')) { return; } $auth = new Auth('Config', 'Session', 'Auth_Admin'); $isAuthed = $auth->getAuthStorage()->read(); if (!$isAuthed) { $application = $e->getApplication(); $event = $application->getEventManager(); $errorController = 'Core\\Admin\\Controller\\ErrorController'; $router->setParam('controller', $errorController); $router->setParam('action', 'index'); $controllerLoader = $application->getServiceManager()->get('ControllerLoader'); $controllerLoader->setInvokableClass($errorController, $errorController); /* $e->setError(\Core\Admin\Controller\ErrorController::ERROR_UNAUTHORIZED) ->setController($errorController) ->setControllerClass($errorController); */ //$results = $event->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e); /* throw new Exception\UnauthorizedException(printf( 'Unauthorized admin resource' )); */ } }