From e94d03f7f281e133f50f73294e73b96167bbd3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Wed, 7 Oct 2026 15:35:25 +0200 Subject: [PATCH 1/2] fix: BearerAuth should not check for already loggedin user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/lib/Connector/Sabre/BearerAuth.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/BearerAuth.php b/apps/dav/lib/Connector/Sabre/BearerAuth.php index 305f79cb0e082..35875d1363295 100644 --- a/apps/dav/lib/Connector/Sabre/BearerAuth.php +++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php @@ -4,6 +4,7 @@ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ + namespace OCA\DAV\Connector\Sabre; use OCP\AppFramework\Http; @@ -42,10 +43,7 @@ private function setupUserFs($userId) { public function validateBearerToken($bearerToken) { \OC_Util::setupFS(); - if (!$this->userSession->isLoggedIn()) { - $this->userSession->tryTokenLogin($this->request); - } - if ($this->userSession->isLoggedIn()) { + if ($this->userSession->tryTokenLogin($this->request)) { return $this->setupUserFs($this->userSession->getUser()->getUID()); } From c39bf4151c51ae5fe0eb97b9ea4cf6ff8f9b1db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 3 Nov 2026 15:37:10 +0100 Subject: [PATCH 2/2] fix(tests): Fix BearerAuthTest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php index e85158db083b2..285e6df8d836d 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php @@ -5,6 +5,7 @@ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ + namespace OCA\DAV\Tests\unit\Connector\Sabre; use OC\User\Session; @@ -50,12 +51,9 @@ public function testValidateBearerTokenNotLoggedIn(): void { public function testValidateBearerToken(): void { $this->userSession - ->expects($this->exactly(2)) - ->method('isLoggedIn') - ->willReturnOnConsecutiveCalls( - false, - true, - ); + ->expects($this->once()) + ->method('tryTokenLogin') + ->willReturn(true); $user = $this->createMock(IUser::class); $user ->expects($this->once())