@@ -83,7 +83,7 @@ public function authenticateUser(UserInterface $user, AuthenticatorInterface $au
8383 $ token = $ this ->eventDispatcher ->dispatch (new AuthenticationTokenCreatedEvent ($ token , $ passport ))->getAuthenticatedToken ();
8484
8585 // authenticate this in the system
86- return $ this ->handleAuthenticationSuccess ($ token , $ passport , $ request , $ authenticator );
86+ return $ this ->handleAuthenticationSuccess ($ token , $ passport , $ request , $ authenticator, $ this -> tokenStorage -> getToken () );
8787 }
8888
8989 public function supports (Request $ request ): ?bool
@@ -165,6 +165,7 @@ private function executeAuthenticators(array $authenticators, Request $request):
165165 private function executeAuthenticator (AuthenticatorInterface $ authenticator , Request $ request ): ?Response
166166 {
167167 $ passport = null ;
168+ $ previousToken = $ this ->tokenStorage ->getToken ();
168169
169170 try {
170171 // get the passport from the Authenticator
@@ -213,7 +214,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
213214 }
214215
215216 // success! (sets the token on the token storage, etc)
216- $ response = $ this ->handleAuthenticationSuccess ($ authenticatedToken , $ passport , $ request , $ authenticator );
217+ $ response = $ this ->handleAuthenticationSuccess ($ authenticatedToken , $ passport , $ request , $ authenticator, $ previousToken );
217218 if ($ response instanceof Response) {
218219 return $ response ;
219220 }
@@ -223,7 +224,7 @@ private function executeAuthenticator(AuthenticatorInterface $authenticator, Req
223224 return null ;
224225 }
225226
226- private function handleAuthenticationSuccess (TokenInterface $ authenticatedToken , Passport $ passport , Request $ request , AuthenticatorInterface $ authenticator ): ?Response
227+ private function handleAuthenticationSuccess (TokenInterface $ authenticatedToken , Passport $ passport , Request $ request , AuthenticatorInterface $ authenticator, ? TokenInterface $ previousToken ): ?Response
227228 {
228229 $ this ->tokenStorage ->setToken ($ authenticatedToken );
229230
@@ -233,7 +234,7 @@ private function handleAuthenticationSuccess(TokenInterface $authenticatedToken,
233234 $ this ->eventDispatcher ->dispatch ($ loginEvent , SecurityEvents::INTERACTIVE_LOGIN );
234235 }
235236
236- $ this ->eventDispatcher ->dispatch ($ loginSuccessEvent = new LoginSuccessEvent ($ authenticator , $ passport , $ authenticatedToken , $ request , $ response , $ this ->firewallName ));
237+ $ this ->eventDispatcher ->dispatch ($ loginSuccessEvent = new LoginSuccessEvent ($ authenticator , $ passport , $ authenticatedToken , $ request , $ response , $ this ->firewallName , $ previousToken ));
237238
238239 return $ loginSuccessEvent ->getResponse ();
239240 }
0 commit comments