From 89d075d6aae162a73e172ac3456a8b35bd63e02c Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Sat, 6 Jan 2024 09:03:59 +0100 Subject: [PATCH] fix(session): Avoid two useless authtoken DB queries for every anonymous request Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- lib/private/User/Session.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 5689de3995f76..39b2341278d8c 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -858,6 +858,13 @@ public function tryTokenLogin(IRequest $request) { return false; } + // Check if the request had sent a cookie with the instance id as name + // If there is no cookie, this is a new session + $instanceId = $this->config->getSystemValueString('instanceid'); + if (is_null($request->getCookie($instanceId))) { + return false; + } + try { $dbToken = $this->tokenProvider->getToken($token); } catch (InvalidTokenException $e) {