src/MyCmcmApi/EventListener/AuthenticationEventListener.php line 11

Open in your IDE?
  1. <?php
  2. namespace PaperKite\MyCmcmApi\EventListener;
  3. use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
  4. use Lightbulb\Symfony\Exception\ForbiddenException;
  5. use PaperKite\MyCmcmApi\Entity\MyCmcmApiUserInterface;
  6. class AuthenticationEventListener
  7. {
  8.     public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event): void
  9.     {
  10.         $user $event->getUser();
  11.         if (true === $user instanceof MyCmcmApiUserInterface) {
  12.             if (null === $user->getValidatedAt()) {
  13.                 throw new ForbiddenException('Email must be validated to login');
  14.             }
  15.         }
  16.     }
  17. }