From 01f5d735e22a6ccb6fab75849d477635c6631606 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 14 Oct 2026 09:03:58 +0200 Subject: [PATCH] add fallback for userSession->getUser() --- lib/Controller/SessionController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php index c18ccb3ba1c..0c15e6ee0a8 100644 --- a/lib/Controller/SessionController.php +++ b/lib/Controller/SessionController.php @@ -76,7 +76,7 @@ public function create(string $type, int $id, ?string $baseVersionEtag = null): public function close(string $documentId, int $sessionId, string $sessionToken): DataResponse { // We also want this to work with a session that has already been closed. // So we cannot rely on RequireDocumentSession to retrieve the user. - $user = $this->userSession->getUser(); + $user = $this->userSession->getUser() ?? $this->getSessionUser($documentId, $sessionId, $sessionToken); if ($user === null) { throw new InvalidSessionException(); } @@ -156,4 +156,14 @@ private function restoreSessionUser(): void { $this->userSession->setUser($this->userToRestore); } } + + private function getSessionUser(string $documentId, int $sessionId, string $sessionToken): ?IUser { + $session = $this->sessionService->getSession($documentId, $sessionId, $sessionToken); + if ($session === null || $session->isGuest()) { + return null; + } + + $user = $this->userManager->get($session->getUserId()); + return $user?->isEnabled() ? $user : null; + } }