<?php
namespace PaperKite\MyCmcmApi\EventListener;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
use Lightbulb\Symfony\Exception\ForbiddenException;
use PaperKite\MyCmcmApi\Entity\MyCmcmApiUserInterface;
class AuthenticationEventListener
{
public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event): void
{
$user = $event->getUser();
if (true === $user instanceof MyCmcmApiUserInterface) {
if (null === $user->getValidatedAt()) {
throw new ForbiddenException('Email must be validated to login');
}
}
}
}