예제 #1
0
 public function logout()
 {
     RestrictAccess::_for(RestrictAccess::GUESTS, '/');
     if ($this->userRepository->logout()) {
         Redirect::guests('/');
     }
 }
예제 #2
0
 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;
 }
예제 #3
0
 public function postBackgroundImageRemove()
 {
     $this->settingsRepository->removeBackgroundImage($_POST);
     Redirect::to('/settings/background');
 }
예제 #4
0
 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');
 }
예제 #5
0
 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('/');
 }