From 320cc97ad8ca0ca7c472724e2d283b77f984ecb2 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 16 Jun 2021 12:48:33 +0100 Subject: [PATCH] Replace getCollectionFirst with getDocument Should be faster due to redis caching --- app/controllers/api/account.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index ffb6c2cf0a..6580e415ec 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -993,15 +993,9 @@ App::get('/v1/account/sessions/:sessionId') ? Auth::sessionVerify($user->getAttribute('sessions'), Auth::$secret) : $sessionId; - $session = $projectDB->getCollectionFirst([ // Get user by sessionId - 'limit' => 1, - 'filters' => [ - '$collection='.Database::SYSTEM_COLLECTION_SESSIONS, - '$id='.$sessionId, - ], - ]); + $session = $projectDB->getDocument($sessionId); // get user by session ID - if ($session == false) { + if (empty($session->getId()) || Database::SYSTEM_COLLECTION_SESSIONS != $session->getCollection()) { throw new Exception('Session not found', 404); };