Skip to content
Snippets Groups Projects
Commit c52cf7d4 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3320018 by mxh: Account switching for default current user may not work for nested execution

parent ed05dc73
No related branches found
No related tags found
No related merge requests found
......@@ -22,13 +22,6 @@ class EcaExecutionSwitchAccountSubscriber extends EcaBase {
*/
protected AccountSwitcherInterface $accountSwitcher;
/**
* A flag indicating whether an account switch was done.
*
* @var bool
*/
protected bool $switched = FALSE;
/**
* Flag indicating whether the user objects have been initialized.
*
......@@ -118,9 +111,10 @@ class EcaExecutionSwitchAccountSubscriber extends EcaBase {
* The according event.
*/
public function onBeforeInitialExecution(BeforeInitialExecutionEvent $before_event): void {
if (self::$modelUser && !$this->switched) {
if (self::$modelUser) {
$this->accountSwitcher->switchTo(self::$modelUser);
$this->switched = TRUE;
$switch_account = TRUE;
$before_event->setPrestate('switch_account', $switch_account);
}
if (self::$sessionUser) {
$this->tokenService->addTokenData('session_user', self::$sessionUser);
......@@ -136,9 +130,8 @@ class EcaExecutionSwitchAccountSubscriber extends EcaBase {
* The according event.
*/
public function onAfterInitialExecution(AfterInitialExecutionEvent $after_event): void {
if ($this->switched) {
if ($after_event->getPrestate('switch_account')) {
$this->accountSwitcher->switchBack();
$this->switched = FALSE;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment