public function logout() { RestrictAccess::_for(RestrictAccess::GUESTS, '/'); if ($this->userRepository->logout()) { Redirect::guests('/'); } }
public static function _for($role, $redirectLocation) { $userRepository = Injector::call('\\Nanozen\\Repositories\\UserRepository'); if ($role == self::LOGGED) { if ($userRepository->hasLogged()) { Redirect::to($redirectLocation); return; } return; } if ($role == self::GUESTS) { if (!$userRepository->hasLogged()) { Redirect::to($redirectLocation); return; } return; } $loggedUser = $userRepository->find(['id' => Session::get('id')]); if (is_string($role) && $role != "") { if (self::checkSingleRole($role, $loggedUser)) { Redirect::to($redirectLocation); } } if (is_array($role) && !empty($role)) { if (self::checkForManyRoles($role, $loggedUser)) { Redirect::to($redirectLocation); } } return true; }
public function postBackgroundImageRemove() { $this->settingsRepository->removeBackgroundImage($_POST); Redirect::to('/settings/background'); }
public function delete($id) { AllowAccess::to([UserRoles::ADMIN, UserRoles::EDITOR], '/'); $result = $this->blockRepository->remove($id); if (!$result) { Redirect::loggedUser('/blocks/' . $id . '/edit'); } Redirect::loggedUser('/back'); }
public function postSetupHomepage() { AllowAccess::to(['admin', 'editor'], '/'); if (isset($_POST['homepageId'])) { $homepageId = $_POST['homepageId']; } else { Session::flash('flash_messages', 'Something went wrong. Please try again!'); Redirect::to('pages/homepage'); } $result = $this->pageRepository->setHomepage($homepageId); if (!$result) { Redirect::loggedUser('/pages/homepage'); } Redirect::to('/'); }