@@ -158,6 +158,8 @@ private function executeAuthenticators(array $authenticators, Request $request):
158
158
159
159
private function executeAuthenticator (AuthenticatorInterface $ authenticator , Request $ request ): ?Response
160
160
{
161
+ $ passport = null ;
162
+
161
163
try {
162
164
// get the passport from the Authenticator
163
165
$ passport = $ authenticator ->authenticate ($ request );
@@ -198,7 +200,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
198
200
return null ;
199
201
} catch (AuthenticationException $ e ) {
200
202
// oh no! Authentication failed!
201
- $ response = $ this ->handleAuthenticationFailure ($ e , $ request , $ authenticator );
203
+ $ response = $ this ->handleAuthenticationFailure ($ e , $ request , $ authenticator, $ passport );
202
204
if ($ response instanceof Response) {
203
205
return $ response ;
204
206
}
@@ -229,7 +231,7 @@ private function handleAuthenticationSuccess(TokenInterface $authenticatedToken,
229
231
/**
230
232
* Handles an authentication failure and returns the Response for the authenticator.
231
233
*/
232
- private function handleAuthenticationFailure (AuthenticationException $ authenticationException , Request $ request , AuthenticatorInterface $ authenticator ): ?Response
234
+ private function handleAuthenticationFailure (AuthenticationException $ authenticationException , Request $ request , AuthenticatorInterface $ authenticator, ? PassportInterface $ passport ): ?Response
233
235
{
234
236
if (null !== $ this ->logger ) {
235
237
$ this ->logger ->info ('Authenticator failed. ' , ['exception ' => $ authenticationException , 'authenticator ' => \get_class ($ authenticator )]);
@@ -240,7 +242,7 @@ private function handleAuthenticationFailure(AuthenticationException $authentica
240
242
$ this ->logger ->debug ('The "{authenticator}" authenticator set the failure response. ' , ['authenticator ' => \get_class ($ authenticator )]);
241
243
}
242
244
243
- $ this ->eventDispatcher ->dispatch ($ loginFailureEvent = new LoginFailureEvent ($ authenticationException , $ authenticator , $ request , $ response , $ this ->firewallName ));
245
+ $ this ->eventDispatcher ->dispatch ($ loginFailureEvent = new LoginFailureEvent ($ authenticationException , $ authenticator , $ request , $ response , $ this ->firewallName , $ passport ));
244
246
245
247
// returning null is ok, it means they want the request to continue
246
248
return $ loginFailureEvent ->getResponse ();
0 commit comments