@@ -1469,16 +1469,15 @@ this as the locale for the given user. To accomplish this, you can hook into
14691469the login process and update the user's session with this locale value before
14701470they are redirected to their first page.
14711471
1472- To do this, you need an event subscriber on the ``security.interactive_login ``
1472+ To do this, you need an event subscriber on the ``LoginSuccessEvent::class ``
14731473event::
14741474
14751475 // src/EventSubscriber/UserLocaleSubscriber.php
14761476 namespace App\EventSubscriber;
14771477
14781478 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
14791479 use Symfony\Component\HttpFoundation\RequestStack;
1480- use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
1481- use Symfony\Component\Security\Http\SecurityEvents;
1480+ use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
14821481
14831482 /**
14841483 * Stores the locale of the user in the session after the
@@ -1491,9 +1490,9 @@ event::
14911490 ) {
14921491 }
14931492
1494- public function onInteractiveLogin(InteractiveLoginEvent $event): void
1493+ public function onLoginSuccess(LoginSuccessEvent $event): void
14951494 {
1496- $user = $event->getAuthenticationToken()-> getUser();
1495+ $user = $event->getUser();
14971496
14981497 if (null !== $user->getLocale()) {
14991498 $this->requestStack->getSession()->set('_locale', $user->getLocale());
@@ -1503,7 +1502,7 @@ event::
15031502 public static function getSubscribedEvents(): array
15041503 {
15051504 return [
1506- SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin ',
1505+ LoginSuccessEvent::class => 'onLoginSuccess ',
15071506 ];
15081507 }
15091508 }
0 commit comments