Answer the question
In order to leave comments, you need to log in
Why do exceptions come from DaoAuthenticationProvider and not from custom auth provider?
class FormAuthenticator implements SimpleFormAuthenticatorInterface
{
public function authenticateToken(
TokenInterface $unAuthenticatedToken,
UserProviderInterface $userProvider,
$providerKey) : UsernamePasswordToken
{
throw new CustomUserMessageAuthenticationException('User not found22222222');
CustomUserMessageAuthenticationException
with the message User not found22222222
.public function onAuthenticationFailure(Request $request, AuthenticationException $exception) : Response
{
dump($exception instanceof AuthenticationServiceException ); // true
exit;
class DaoAuthenticationProvider extends UserAuthenticationProvider
{
...
Выкидывает ексепшены отсюда
protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
{
...
if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
throw new BadCredentialsException('The presented password is invalid.');
}
}
}
// И отсюда
protected function retrieveUser($username, UsernamePasswordToken $token)
{
...
} catch (UsernameNotFoundException $e) {
$e->setUsername($username);
throw $e;
} catch (\Exception $e) {
// ТУТ
$e = new AuthenticationServiceException($e->getMessage(), 0, $e);
$e->setToken($token);
throw $e;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question