[Security] Initialize SwitchUserEvent::targetUser on attemptExitUser

The `SwitchUserEvent` is triggered in case an account is switched. This works okay while switching to the user, but on exit the `SwitchUserEvent` is triggered again with the original User. That User was not initialized by the provider yet.

load user by UserInterface instead of username
This commit is contained in:
Richard van Laak 2015-06-10 09:49:02 +02:00 committed by Christian Flothmann
parent 7e418fd954
commit 01ee3f6cda
1 changed files with 2 additions and 1 deletions

View File

@ -163,7 +163,8 @@ class SwitchUserListener implements ListenerInterface
}
if (null !== $this->dispatcher) {
$switchEvent = new SwitchUserEvent($request, $original->getUser());
$user = $this->provider->refreshUser($original->getUser());
$switchEvent = new SwitchUserEvent($request, $user);
$this->dispatcher->dispatch(SecurityEvents::SWITCH_USER, $switchEvent);
}