/** * Hàm xử lý phân quyềnh người dùng * @param Dispatcher $dispatcher * * */ public function beforeExecuteRoute(Dispatcher $dispatcher) { $auth = new \Modules\Library\Auth\Auth(); if (!empty($auth->getIdentity())) { $controllerName = $dispatcher->getControllerName(); $actionName = $dispatcher->getActionName(); $acl = new \Modules\Library\Acl\Acl(); if ($auth->getPermission() !== "full") { if (!$acl->isAllowed($auth->getPermission(), $controllerName, $actionName)) { if ($acl->isAllowed($auth->getPermission(), "index", "index")) { $this->flash->error("Từ chối truy cập"); $dispatcher->forward(array('modules' => 'backend', 'controller' => 'index', 'action' => 'index')); } else { die; } } } } else { $this->response->redirect("admin/login"); } }
/** * Closes the session */ public function logoutAction() { $auth = new \Modules\Library\Auth\Auth(); $auth->remove(); $this->response->redirect('admin/login'); }