[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:
parent
7e418fd954
commit
01ee3f6cda
@ -163,7 +163,8 @@ class SwitchUserListener implements ListenerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->dispatcher) {
|
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);
|
$this->dispatcher->dispatch(SecurityEvents::SWITCH_USER, $switchEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user