<?php
namespace App\EventListener;
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTInvalidEvent;
use Lexik\Bundle\JWTAuthenticationBundle\Response\JWTAuthenticationFailureResponse;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Events;
class JWTInvalidListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
Events::JWT_INVALID => 'onJWTInvalid',
];
}
public function onJWTInvalid(JWTInvalidEvent $event)
{
$response = new JWTAuthenticationFailureResponse('You have changed email, please login again', 401);
$event->setResponse($response);
}
}