src/EventListener/AuthenticationSuccessListener.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Entity\User;
  4. use Symfony\Component\DependencyInjection\ContainerInterface;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
  7. /**
  8.  * Description of JWTAuthenticatedListener
  9.  *
  10.  * @author Bader
  11.  *
  12.  */
  13. class AuthenticationSuccessListener
  14. {
  15.     /**
  16.      * @param AuthenticationSuccessEvent $event
  17.      */
  18.     public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event)
  19.     {
  20.         $user $event->getUser();
  21.         $event->setData([
  22.             'data' => $event->getData(),
  23.             'id' => $user->getId(),
  24.             'userName' => $user->getUsername(),
  25.             'firstName' => $user->getFirstName(),
  26.             'lastName' => $user->getLastName(),
  27.             'path' => $user->getPath(),
  28.             'group'=> $user->getGroupe()->getName(),
  29.             'job'=> $user->getFonction()->getName(),
  30.             'phone'=> $user->getPhone(),  
  31.         ]);
  32.   
  33.     }
  34.   
  35. }