src/EventListener/JWTNotFoundListener.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTNotFoundEvent;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. class JWTNotFoundListener
  6. {
  7.     /**
  8.      * @param JWTNotFoundEvent $event
  9.      */
  10.     public function onJWTNotFound(JWTNotFoundEvent $event)
  11.     {
  12.         // Custom status code & error message
  13.         $data = [
  14.             'code'    => JsonResponse::HTTP_FORBIDDEN,
  15.             'message' => "Token introuvable",
  16.         ];
  17.         
  18.         $response = new JsonResponse($dataJsonResponse::HTTP_FORBIDDEN);
  19.         
  20.         $event->setResponse($response);
  21.     }
  22. }