Skip to content

Commit 14a2c8e

Browse files
hangerritssolracsf
andauthored
Apply suggestion from @solracsf
agree, that's better Co-authored-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> Signed-off-by: Han Gerrits <han@newtech.studio>
1 parent 14378e9 commit 14a2c8e

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

lib/User/Backend.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,17 @@ public function getCurrentUserId(): string {
389389
*/
390390
private function setSessionUser(string $userId): void {
391391
try {
392-
$user = $this->userManager->get($userId);
393-
if ($user !== null) {
394-
$userSession = Server::get(IUserSession::class);
395-
$userSession->setUser($user);
392+
$userSession = Server::get(IUserSession::class);
393+
$currentUser = $userSession->getUser();
394+
395+
// Only fetch and set if the session doesn't already have this user
396+
if ($currentUser === null || $currentUser->getUID() !== $userId) {
397+
$user = $this->userManager->get($userId);
398+
if ($user !== null) {
399+
$userSession->setUser($user);
400+
}
396401
}
397-
} catch (Throwable $e) {
402+
} catch (\Throwable $e) {
398403
$this->logger->debug('Failed to set session user after bearer validation: ' . $e->getMessage());
399404
}
400405
}

0 commit comments

Comments
 (0)