src/EventListener/JWTNotFoundListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTNotFoundEvent;
  4. use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse;
  5. use Symfony\Contracts\Translation\TranslatorInterface;
  6. class JWTNotFoundListener
  7. {
  8.     private TranslatorInterface $translator;
  9.     public function __construct(TranslatorInterface $translator)
  10.     {
  11.         $this->translator $translator;
  12.     }
  13.     public function onJWTNotFound(JWTNotFoundEvent $event): void
  14.     {
  15.         /** @var JWTAuthenticationFailureResponse $response */
  16.         $response $event->getResponse();
  17.         $response->setMessage($this->translator->trans('Missing token.', [], 'security'));
  18.     }
  19. }