src/EventListener/JWTCreatedListener.php line 12

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\EventListener;
  4. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent;
  5. class JWTCreatedListener {
  6.   public function onJWTCreated(JWTCreatedEvent $event) {
  7.     $user $event->getUser();
  8.     //merge with existing event data
  9.     $payload array_merge(
  10.       $event->getData(),
  11.       [
  12.         'id' => $user->getId()
  13.       ]
  14.     );
  15.     $event->setData($payload);
  16.   }
  17. }