标签:invalid response catch set expired json abs auth return
通过jwt-auth提供的:
use Tymon\JWTAuth\Exceptions\JWTException;
public function getAuthenticatedUser() { try { if (! $user = JWTAuth::parseToken()->authenticate()) { return response()->json([‘user_not_found‘], 404); } } catch (TokenExpiredException $e) { return response()->json([‘token_expired‘], $e->getStatusCode()); } catch (TokenInvalidException $e) { return response()->json([‘token_invalid‘], $e->getStatusCode()); } catch (JWTException $e) { return response()->json([‘token_absent‘], $e->getStatusCode()); } // the token is valid and we have found the user via the sub claim return response()->json(compact(‘user‘)); }
标签:invalid response catch set expired json abs auth return
原文地址:http://www.cnblogs.com/lindoubao/p/7396706.html