src/EventListener/JWTInvalidListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTInvalidEvent;
  4. use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Lexik\Bundle\JWTAuthenticationBundle\Events;
  7. class JWTInvalidListener implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents()
  10.     {
  11.         return [
  12.             Events::JWT_INVALID => 'onJWTInvalid',
  13.         ];
  14.     }
  15.     public function onJWTInvalid(JWTInvalidEvent $event)
  16.     {
  17.         $response = new JWTAuthenticationFailureResponse('You have changed email, please login again'401);
  18.         $event->setResponse($response);
  19.     }
  20. }