File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 3333
3434namespace OC \Core \Controller ;
3535
36+ use OC \AppFramework \Http \Request ;
3637use OC \Authentication \Login \Chain ;
3738use OC \Authentication \Login \LoginData ;
38- use OC \Authentication \TwoFactorAuth \Manager ;
3939use OC \Security \Bruteforce \Throttler ;
4040use OC \User \Session ;
4141use OC_App ;
@@ -128,7 +128,11 @@ public function logout() {
128128
129129 $ this ->session ->set ('clearingExecutionContexts ' , '1 ' );
130130 $ this ->session ->close ();
131- $ response ->addHeader ('Clear-Site-Data ' , '"cache", "storage" ' );
131+
132+ if (!$ this ->request ->isUserAgent ([Request::USER_AGENT_CHROME , Request::USER_AGENT_ANDROID_MOBILE_CHROME ])) {
133+ $ response ->addHeader ('Clear-Site-Data ' , '"cache", "storage" ' );
134+ }
135+
132136 return $ response ;
133137 }
134138
Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ public function testLogoutWithoutToken() {
128128 ->method ('getCookie ' )
129129 ->with ('nc_token ' )
130130 ->willReturn (null );
131+ $ this ->request
132+ ->expects ($ this ->once ())
133+ ->method ('isUserAgent ' )
134+ ->willReturn (false );
131135 $ this ->config
132136 ->expects ($ this ->never ())
133137 ->method ('deleteUserValue ' );
@@ -142,12 +146,36 @@ public function testLogoutWithoutToken() {
142146 $ this ->assertEquals ($ expected , $ this ->loginController ->logout ());
143147 }
144148
149+ public function testLogoutNoClearSiteData () {
150+ $ this ->request
151+ ->expects ($ this ->once ())
152+ ->method ('getCookie ' )
153+ ->with ('nc_token ' )
154+ ->willReturn (null );
155+ $ this ->request
156+ ->expects ($ this ->once ())
157+ ->method ('isUserAgent ' )
158+ ->willReturn (true );
159+ $ this ->urlGenerator
160+ ->expects ($ this ->once ())
161+ ->method ('linkToRouteAbsolute ' )
162+ ->with ('core.login.showLoginForm ' )
163+ ->willReturn ('/login ' );
164+
165+ $ expected = new RedirectResponse ('/login ' );
166+ $ this ->assertEquals ($ expected , $ this ->loginController ->logout ());
167+ }
168+
145169 public function testLogoutWithToken () {
146170 $ this ->request
147171 ->expects ($ this ->once ())
148172 ->method ('getCookie ' )
149173 ->with ('nc_token ' )
150174 ->willReturn ('MyLoginToken ' );
175+ $ this ->request
176+ ->expects ($ this ->once ())
177+ ->method ('isUserAgent ' )
178+ ->willReturn (false );
151179 $ user = $ this ->createMock (IUser::class);
152180 $ user
153181 ->expects ($ this ->once ())
You can’t perform that action at this time.
0 commit comments