<?php
namespace App\EventListener;
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTNotFoundEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
class JWTNotFoundListener
{
/**
* @param JWTNotFoundEvent $event
*/
public function onJWTNotFound(JWTNotFoundEvent $event)
{
// Custom status code & error message
$data = [
'code' => JsonResponse::HTTP_FORBIDDEN,
'message' => "Token introuvable",
];
$response = new JsonResponse($data, JsonResponse::HTTP_FORBIDDEN);
$event->setResponse($response);
}
}