add Johan code

This commit is contained in:
Olivier PARPAILLON
2024-11-19 16:09:46 +01:00
parent e5fdaadcd8
commit 59c2d1445a

View File

@@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator; use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
@@ -45,6 +46,10 @@ class LoginFormAuthenticator extends AbstractAuthenticator
'pseudo' => $identifier 'pseudo' => $identifier
]); ]);
if (!$user || $user->isActif()) {
throw new UserNotFoundException('Utilisateur non trouvé');
}
if (!$user) { if (!$user) {
throw new AuthenticationException('Identifiant ou mot de passe incorrect.'); throw new AuthenticationException('Identifiant ou mot de passe incorrect.');
} }