Пример #1
0
 public static function checkUser()
 {
     // Предотвращение перехвата сеанса
     $sessUserId = Session::get('user_id');
     if (!isset($sessUserId)) {
         Session::destroy();
         //             unset($this->user);
         Session::setMsg('Произошла ошибка. Пожалуйста авторизуйтесь заново', 'warning');
         return FALSE;
     }
     // Предотвращение фиксации сеанса (включая ini_set('session.use_only_cookies', true);)
     $sessGenerated = Session::get('generated');
     if (!isset($sessGenerated) || $sessGenerated < time() - 30) {
         session_regenerate_id();
         $_SESSION['generated'] = time();
     }
     if ($sessUserId) {
         $userModel = new UserTableModel();
         $userModel->setId($sessUserId);
         $userModel->setTable('user');
         $username = $userModel->readRecordsById('id', 'username')[0]['username'];
         Session::set('username', $username);
         return TRUE;
     }
     return FALSE;
 }
Пример #2
0
 private function redirToAuth()
 {
     Session::set('referer', $_SERVER['REQUEST_URI']);
     if (!Session::get('user_id')) {
         if ($this->getController() === 'AdminController') {
             header('Location: /admin/login');
             exit;
         } else {
             header('Location: /user/login');
             exit;
         }
     } else {
         $model = new Model();
         $output = $model->render('../views/status/403.php', 'status');
         $this->setPage($output);
     }
 }
Пример #3
0
 static function redirectChecker()
 {
     if (filter_has_var(INPUT_GET, 'redirect')) {
         Session::set('redirect', filter_input(INPUT_GET, 'redirect', FILTER_SANITIZE_URL));
         if (filter_has_var(INPUT_GET, 'hash')) {
             Session::set('redirectHash', filter_input(INPUT_GET, 'hash', FILTER_SANITIZE_STRING));
         }
     } else {
         return FALSE;
     }
 }
Пример #4
0
 public function auth($userId)
 {
     Session::init();
     //         $this->setToken();
     Session::set('user_id', $userId);
 }
Пример #5
0
 public static function setUserMsg($body, $type = 'info')
 {
     Session::set('userMsg', ['type' => $type, 'body' => $body]);
 }