invalidate() public static method

Invalidate a token (add it to the blacklist).
public static invalidate ( mixed $token = false ) : boolean
$token mixed
return boolean
Ejemplo n.º 1
1
 public function logout()
 {
     //获取当前用户token
     $token = \JWTAuth::getToken();
     //让token失效
     try {
         \JWTAuth::invalidate($token);
         return return_rest('1', '', '已退出登录');
     } catch (\Exception $e) {
         return return_rest('0', '', $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 public static function invalidateTokenByUserId($userId)
 {
     $maps = \DB::table('token_map')->where('user_id', $userId)->get();
     if (!empty($maps) && is_array($maps)) {
         foreach ($maps as $map) {
             try {
                 \JWTAuth::invalidate($map->token);
             } catch (TokenExpiredException $e) {
                 //If the token is expired already then do nothing here.
             }
         }
     }
     return \DB::table('token_map')->where('user_id', $userId)->delete();
 }
Ejemplo n.º 3
0
 /**
  * Log the user out of the application.
  *
  * @return  Illuminate\Http\Response
  */
 public function getLogout()
 {
     JWTAuth::invalidate(JWTAuth::getToken());
     return $this->response->array(array('message' => 'Successfully logged out'));
 }