jeudi 10 mai 2018

tymon/jwt-auth for laravel 5.4 refresh token

I recently using laravel 5.4 and i want to use tymon/jwt-auth package to secure my APIs by sending the access token but my issues happened when token expired i can't refresh it before expired and i expected the token will be refreshed automatically

public function handle($request, Closure $next)
{
    try{
        $user = JWTAuth::parseToken()->authenticate();
    }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 is required']);
        }
    }
   return $next($request);
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2IeyUjq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire