Exemple #1
0
 private function autoLogin()
 {
     try {
         if (\Session::has('userID')) {
         } else {
             //try set session from cookies if no session
             if (!empty(\Cookie::get('userID'))) {
                 $field = array('field' => '_id', 'value' => (string) \Cookie::get('userID'));
                 if (Auth::isExists($field)) {
                     \Session::put('userID', \Cookie::get('userID'));
                     //
                     //return \Response::make()->withCookie(\Cookie::make('userID', \Cookie::get('userID') , self::COOKIE_EXPIRE));
                 } else {
                     throw new AuthCheckException('username', 'auth.username.doesnt.exist');
                 }
             } else {
                 //\Session::forget('userID')->withCookie(\Cookie::forget('userID'))->withCookie(\Cookie::forget('userID'));
                 throw new AuthCheckException('userid', 'auth.userid.doesnt.exist');
             }
         }
     } catch (Exception $e) {
         $return = \Response::json(["message" => "Session logout!"], 400);
         \Session::forget('userID');
         return $return->withCookie(Cookie::forget('userID'))->withCookie(Cookie::forget('userID'));
     }
 }
Exemple #2
0
 public static function isWebDeviceAccess()
 {
     $user = Auth::user();
     if (!empty($user['device_type']) && $user['device_type'] == 9) {
         return true;
     }
     return false;
 }
Exemple #3
0
 public function login()
 {
     $input = \Input::get();
     $data = Auth::loginUser($input);
     $result['userID'] = $data['_id']->{'$id'};
     $result['userName'] = $data['username'];
     $result['userEmail'] = $data['email'];
     $result['userPicture'] = $data['picture'];
     $output = \Response::json($result, 200);
     return $output->withCookie(\Cookie::make('userID', $data['_id']->{'$id'}, self::COOKIE_EXPIRE));
 }