Skip to content

Commit 8c01bb9

Browse files
committed
Send Clear-Site-Data expect for Chrome
Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent cd7af39 commit 8c01bb9

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

core/Controller/LoginController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333

3434
namespace OC\Core\Controller;
3535

36+
use OC\AppFramework\Http\Request;
3637
use OC\Authentication\Login\Chain;
3738
use OC\Authentication\Login\LoginData;
38-
use OC\Authentication\TwoFactorAuth\Manager;
3939
use OC\Security\Bruteforce\Throttler;
4040
use OC\User\Session;
4141
use 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

tests/Core/Controller/LoginControllerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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())

0 commit comments

Comments
 (0)