1
0
Fork 0
mirror of synced 2024-06-15 09:14:50 +12:00

Replace getCollectionFirst with getDocument

Should be faster due to redis caching
This commit is contained in:
Bradley Schofield 2021-06-16 12:48:33 +01:00
parent cdb8fb8286
commit 320cc97ad8

View file

@ -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);
};