$app->post('auth/refresh-token', ['middleware' => 'jwt.refresh', function() {  
    try {  
        $old_token = JWTAuth::getToken();  
        $token = JWTAuth::refresh($old_token);  
        JWTAuth::invalidate($old_token);  
    } catch (TokenExpiredException $e) {  
        throw new AuthException(  
            Constants::get('error_code.refresh_token_expired'),  
            trans('errors.refresh_token_expired'), $e);  
    } catch (JWTException $e) {  
        throw new AuthException(  
            Constants::get('error_code.token_invalid'),  
            trans('errors.token_invalid'), $e);  
    }  
  
    return response()->json(compact('token'));  
}]); 

 

相关文章:

  • 2022-12-23
  • 2021-10-15
  • 2021-06-29
  • 2021-07-30
  • 2018-03-08
  • 2022-02-23
  • 2021-06-30
  • 2021-11-27
猜你喜欢
  • 2021-10-18
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案