/** * Method checks if admin panel route is open and then valid permission to * stay there. If user is admin (or moderator) method loads necessary extensions */ public function loadAdmin() { if ($this->http->isAdmin()) { // If not logged open login panel if (!$this->user->isUserLoggedIn()) { $this->view->loadFile('../../admin/extensions/Index/login.html'); exit; } // Check permissions if ($this->user->getUserSession()->getRole() != 'admin') { Server::headerLocation(); // Go to main page } // Admin view helper classes $this->viewHelper->add($this->conf['adminViewHelper'] ?? []); $this->registry->set('App\\Admin\\Admin', new Admin($this->adminExtension, $this->yaml)); } }
/** * * @param \UserAuth\User $user */ private function checkIfUserIsLogged(\UserAuth\User $user) { if (!$user->isUserLoggedIn()) { Server::headerLocationReferer(); } }
/** * * @return boolean */ public function isUserLoggedIn() : bool { return $this->user->isUserLoggedIn(); }