Now when tokes is expired it returns message: Token has expired. How change this message and how change default exception on custom?

1 Answers

1
Prafulla Kumar Sahu On Best Solutions

In Handler.php

may be you just need to check the exception instance and send the message you want to send to end point.

Something like this should work fine.

public function render($request, Exception $exception)
    if ($exception instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException) {
       return $request->expectsJson()
          ? response()->json([
               'status' => 401,
               'response' => 'Your message'
          ]) : abort(201);
      }
}