diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php index 7823afd622c..3ac7cb7d3df 100644 --- a/lib/Controller/SessionController.php +++ b/lib/Controller/SessionController.php @@ -117,11 +117,14 @@ public function mention(int $documentId, int $sessionId, string $sessionToken, s private function loginSessionUser(int $documentId, int $sessionId, string $sessionToken) { $currentSession = $this->sessionService->getSession($documentId, $sessionId, $sessionToken); if ($currentSession !== false && !$this->userSession->isLoggedIn()) { - $user = $this->userManager->get($currentSession->getUserId()); - if ($user !== null) { - $this->restoreUser = true; - $this->userToRestore = $this->userSession->getUser(); - $this->userSession->setUser($user); + $userId = $currentSession->getUserId(); + if ($userId !== false) { + $user = $this->userManager->get($userId); + if ($user !== null) { + $this->restoreUser = true; + $this->userToRestore = $this->userSession->getUser(); + $this->userSession->setUser($user); + } } } }