How to redirect my laravel webpage to login
route if I got a message A token is required
from JWTException
.
You could check the token using a middleware:
class CheckTokenMiddleware
{
public function handle($request, Closure $next)
{
// Check token here.
if (!checkToken($request->token)) {
return redirect('login');
}
return $next($request);
}
}