I am creating an API using Laravel 5.4 framework. Using JWT token, I am however unable to catch the InvalidTokenException when I input a wrong token. Please see my code and advice. Thank you!
$token = $request->token;
try{
$user = JWTAuth::toUser($token);
}catch(\Tymon\JWTAuth\Exceptions\TokenInvalidException $e){ //NOT CATCHING...
$error = 'Invalid token';
return response()->json(compact('error'));
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire