a lot of ui and flash message. Useless af
This commit is contained in:
@@ -17,16 +17,19 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class LoginFormAuthenticator extends AbstractAuthenticator
|
||||
{
|
||||
private $entityManager;
|
||||
private $urlGenerator;
|
||||
private RequestStack $requestStack;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator)
|
||||
public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, RequestStack $requestStack)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
public function supports(Request $request): ?bool
|
||||
@@ -46,12 +49,14 @@ class LoginFormAuthenticator extends AbstractAuthenticator
|
||||
'pseudo' => $identifier
|
||||
]);
|
||||
|
||||
if (!$user || $user->isActif() || $user->getPending()) {
|
||||
throw new UserNotFoundException('Utilisateur non trouvé');
|
||||
if (!$user) {
|
||||
$this->addFlash('error', 'Utilisateur inexistant');
|
||||
throw new AuthenticationException('Identifiant ou mot de passe incorrect.');
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
throw new AuthenticationException('Identifiant ou mot de passe incorrect.');
|
||||
if ($user->isActif() || $user->getPending()) {
|
||||
$this->addFlash('error', "L'utilisateur à été désactivé par un administrateur ou est en attente.");
|
||||
throw new UserNotFoundException('Utilisateur non trouvé');
|
||||
}
|
||||
|
||||
// Utilisation de UserBadge au lieu de Participant directement
|
||||
@@ -70,5 +75,13 @@ class LoginFormAuthenticator extends AbstractAuthenticator
|
||||
{
|
||||
return new RedirectResponse($this->urlGenerator->generate('app_login'));
|
||||
}
|
||||
|
||||
private function addFlash(string $type, string $message): void
|
||||
{
|
||||
$session = $this->requestStack->getSession();
|
||||
if ($session) {
|
||||
$session->getFlashBag()->add($type, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user