From c7bd7b9760a2ef1d087ac1095fca5f75bbb2268e 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 d28a9cfdb84db..7029bf2d254fa 100644 --- a/apps/dav/lib/Connector/Sabre/BearerAuth.php +++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php @@ -21,6 +21,7 @@ * along with this program. If not, see . * */ + namespace OCA\DAV\Connector\Sabre; use OCP\IRequest; @@ -72,10 +73,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 88046e0e7b5f4f725e5e3645042c5d4c13389c6e 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 007b5c90295db..a6253fd3e3552 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php @@ -1,4 +1,5 @@ * @@ -22,6 +23,7 @@ * along with this program. If not, see . * */ + namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\BearerAuth; @@ -66,12 +68,8 @@ public function testValidateBearerTokenNotLoggedIn() { public function testValidateBearerToken() { $this->userSession - ->expects($this->at(0)) - ->method('isLoggedIn') - ->willReturn(false); - $this->userSession - ->expects($this->at(2)) - ->method('isLoggedIn') + ->expects($this->once()) + ->method('tryTokenLogin') ->willReturn(true); $user = $this->createMock(IUser::class); $user