src/Listener/Jwt/JWTInvalidListener.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Listener\Jwt;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTInvalidEvent;
  4. use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. class JWTInvalidListener
  7. {
  8.     /**
  9.      * @var RequestStack
  10.      */
  11.     private $requestStack;
  12.     /**
  13.      * @param RequestStack $requestStack
  14.      */
  15.     public function __construct(RequestStack $requestStack)
  16.     {
  17.         $this->requestStack $requestStack;
  18.     }
  19.     /**
  20.      * @param JWTInvalidEvent $event
  21.      */
  22.     public function onJWTInvalid(JWTInvalidEvent $event)
  23.     {
  24.         $response = new JWTAuthenticationFailureResponse('Your token is invalid, please login again to get a new one'403);
  25.         $event->setResponse($response);
  26.     }
  27. }