src/Listener/JWTDecodedListener.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Listener;
  3. use App\Repository\UserRepository;
  4. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent;
  5. use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTDecodedEvent;
  6. use Symfony\Component\HttpFoundation\RequestStack;
  7. class JWTDecodedListener {
  8.     private $requestStack;
  9.     private $userRepository;
  10.     /**
  11.      * @param RequestStack $requestStack
  12.      * @param UserRepository $userRepository
  13.      * se ejecuta el segundo
  14.      */
  15.     public function __construct(RequestStack $requestStackUserRepository $userRepository)
  16.     {
  17.         $this->requestStack $requestStack;
  18.         $this->userRepository $userRepository;
  19.     }
  20.     public function onJWTDecoded(JWTDecodedEvent $event)
  21.     {
  22.         $request $this->requestStack->getCurrentRequest();
  23.         $data $this->userRepository->findOneByEmail($event->getPayload()['username']);
  24.     }
  25. }