Created
November 29, 2018 16:03
-
-
Save casgin/27abb781312c0b1ef105cfa3850edb3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// === Recupero del Token | |
$token = JWTAuth::getToken(); | |
// --- logica del middleware | |
try { | |
// --- inoltra il token e verifica che sia corretto | |
$user = JWTAuth::toUser($token); | |
} catch (JWTException $e) { | |
if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException) { | |
return response()->json(['token_expired'], $e->getStatusCode()); | |
} else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) { | |
return response()->json(['token_invalid'], $e->getStatusCode()); | |
} else { | |
return response()->json(['error' => 'Token obbligatorio']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment