Example #1
0
 public static function tester()
 {
     $tester = Cache::get('testers', function () {
         $tester = User::where('role', 1)->get();
         Cache::forever('testers', $tester);
     });
     return $tester;
 }
Example #2
0
 public static function init()
 {
     ini_set('session.use_strict_mode', true);
     ini_set('session.use_only_cookies', true);
     session_start();
     if (self::get('user_id')) {
         User::checkUser();
     }
 }
Example #3
0
 private function checkCreds()
 {
     try {
         $st = $this->db->prepare("SELECT `id`, `username`, `email`, `password_hash`, `validated` FROM {$this->table} WHERE `username` = :username");
         $st->execute([':username' => $this->login]);
         if ($st->rowCount() === 1) {
             $user = $st->fetch(PDO::FETCH_ASSOC);
             if (!$user['validated']) {
                 Session::setMsg('Для входа необходимо активировать ваш аккаунт при помощи письма, отправленного на ваш электронный ящик ранее', 'warning');
                 return FALSE;
             }
             if (User::confirmPassword($user['password_hash'], $this->password)) {
                 return $user;
             }
         }
         Session::setMsg('Неверный логин или пароль', 'danger');
         return FALSE;
     } catch (Exception $ex) {
         $ex->getMessage();
     }
 }
Example #4
0
 public function checkUserAction()
 {
     header('Content-type: text/plain; charset=utf-8');
     header('Cache-Control: no-store, no-cache');
     header('Expires: ' . date('r'));
     echo User::checkUser();
 }