diff --git a/lib/User/Backend.php b/lib/User/Backend.php index e06aee48..87d392b4 100644 --- a/lib/User/Backend.php +++ b/lib/User/Backend.php @@ -37,7 +37,6 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; -use OCP\IUserSession; use OCP\Server; use OCP\User\Backend\ABackend; use OCP\User\Backend\ICountUsersBackend; @@ -369,12 +368,10 @@ public function getCurrentUserId(): string { } $this->session->set('last-password-confirm', $this->timeFactory->getTime() + 4 * 365 * 24 * 3600); - $this->setSessionUser($userId); return $userId; } elseif ($this->userExists($tokenUserId)) { $this->checkFirstLogin($tokenUserId); $this->session->set('last-password-confirm', $this->timeFactory->getTime() + 4 * 365 * 24 * 3600); - $this->setSessionUser($tokenUserId); return $tokenUserId; } else { // check if the user exists locally @@ -396,7 +393,6 @@ public function getCurrentUserId(): string { } $this->checkFirstLogin($tokenUserId); $this->session->set('last-password-confirm', $this->timeFactory->getTime() + 4 * 365 * 24 * 3600); - $this->setSessionUser($tokenUserId); return $tokenUserId; } } @@ -417,31 +413,6 @@ private function isAcceptableUserId(mixed $userId): bool { return is_string($userId) && $userId !== '' && trim($userId) !== ''; } - /** - * Set the user in IUserSession after bearer token validation. - * Without this, DI-injected $userId is null in OCS controllers - * and CalDAV plugins, causing 500 errors in Deck, Talk, and Tasks. - * - * Note: IUserSession is resolved via Server::get() rather than constructor - * injection to avoid a circular dependency (IUserSession depends on this Backend). - */ - private function setSessionUser(string $userId): void { - try { - $userSession = Server::get(IUserSession::class); - $currentUser = $userSession->getUser(); - - // Only fetch and set if the session doesn't already have this user - if ($currentUser === null || $currentUser->getUID() !== $userId) { - $user = $this->userManager->get($userId); - if ($user !== null) { - $userSession->setUser($user); - } - } - } catch (\Throwable $e) { - $this->logger->debug('Failed to set session user after bearer validation: ' . $e->getMessage()); - } - } - /** * * Performs first-login initialisation (home folder setup, skeleton copy, events)