src/EventSubscriber/AuthenticationSuccessListener.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class AuthenticationSuccessListener implements EventSubscriberInterface
  6. {
  7.     public function onAuthenticationSuccess(AuthenticationSuccessEvent $event)
  8.     {
  9.         $data $event->getData();
  10.         $user $event->getUser();
  11.         // Ajouter la valeur de l'utilisateur dans le token JWT
  12.         $data['emailUser'] = $user->getEmailUser();
  13.         $event->setData($data);
  14.     }
  15.     public static function getSubscribedEvents()
  16.     {
  17.         return [
  18.             'lexik_jwt_authentication.on_authentication_success' => 'onAuthenticationSuccess',
  19.         ];
  20.     }
  21. }