Skip to content

Commit 22070a5

Browse files
authored
Update locale with new authentication system
For the new authentication system, the LoginSuccessEvent event that is fired after logging in. This is to be updated in the new documentation
1 parent 4aa9eff commit 22070a5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

session/locale_sticky_session.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ event::
148148

149149
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
150150
use Symfony\Component\HttpFoundation\RequestStack;
151-
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
152-
use Symfony\Component\Security\Http\SecurityEvents;
151+
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
153152

154153
/**
155154
* Stores the locale of the user in the session after the
@@ -164,19 +163,19 @@ event::
164163
$this->requestStack = $requestStack;
165164
}
166165

167-
public function onInteractiveLogin(InteractiveLoginEvent $event)
166+
public function onLoginSuccess(LoginSuccessEvent $event): void
168167
{
169-
$user = $event->getAuthenticationToken()->getUser();
168+
$user = $event->getUser();
170169

171170
if (null !== $user->getLocale()) {
172171
$this->requestStack->getSession()->set('_locale', $user->getLocale());
173172
}
174173
}
175174

176-
public static function getSubscribedEvents()
175+
public static function getSubscribedEvents(): array
177176
{
178177
return [
179-
SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
178+
LoginSuccessEvent::class => 'onLoginSuccess',
180179
];
181180
}
182181
}

0 commit comments

Comments
 (0)