Skip to content

Commit e21520a

Browse files
committed
minor #17595 [Security] Update locale with new authentication system (r-ant-2468)
This PR was submitted for the 6.2 branch but it was merged into the 6.3 branch instead. Discussion ---------- [Security] 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 <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 9559087 Update locale with new authentication system
2 parents 4e81af5 + 9559087 commit e21520a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

session.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,16 +1469,15 @@ this as the locale for the given user. To accomplish this, you can hook into
14691469
the login process and update the user's session with this locale value before
14701470
they 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``
14731473
event::
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

Comments
 (0)