@@ -57,12 +57,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
5757 return $ handler ->handle ($ request );
5858 }
5959
60- // if backend user is already simulated
61- // then do not try to simulate again
62- // otherwise the user cannot log off the backend anymore
63- if ($ request ->getCookieParams ()[$ this ->configuration ->getCookieName ()]) {
64- return $ handler ->handle ($ request );
65- }
6660
6761 $ tempBackendUserAuthentication = GeneralUtility::makeInstance (BackendUserAuthentication::class);
6862 $ backendCookieName = $ tempBackendUserAuthentication ->name ;
@@ -80,18 +74,33 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
8074 && $ request ->getCookieParams ()[$ backendCookieName ] === $ request ->getCookieParams ()[$ simulateBeCookieName ]
8175 ) {
8276 $ response = $ handler ->handle ($ request );
77+
78+ if (!$ GLOBALS ['BE_USER ' ] instanceof BackendUserAuthentication) {
79+ $ GLOBALS ['BE_USER ' ] = GeneralUtility::makeInstance (BackendUserAuthentication::class);
80+ $ GLOBALS ['BE_USER ' ]->start ();
81+ }
82+
8383 $ GLOBALS ['BE_USER ' ]->logoff ();
8484
85- return new RedirectResponse (
85+ $ response = new RedirectResponse (
8686 $ request ->getUri (),
8787 307 ,
8888 $ response ->getHeaders ()
8989 );
90+ $ response = $ this ->withSessionCookie ($ response ,$ this ->configuration ->getCookieName (),'' );
91+ return $ response ;
9092 }
9193
9294 return $ handler ->handle ($ request );
9395 }
9496
97+ // if backend user is already simulated
98+ // then do not try to simulate again
99+ // otherwise the user cannot log off the backend anymore
100+ if ($ request ->getCookieParams ()[$ this ->configuration ->getCookieName ()]) {
101+ return $ handler ->handle ($ request );
102+ }
103+
95104 // at this point we know
96105 // 1. user is logged in as frontend user
97106 // 2. user is not logged in as backend user yet
0 commit comments