From 2c46cdcc3cb3aab2a903c33c2f4e5f14d6500145 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 13 Dec 2022 06:08:38 +0000 Subject: [PATCH] add session default and comment --- app/controllers/shared/api.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index dddf8cd8f3..227c3e7e23 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -318,6 +318,12 @@ App::init() } }); +/** + * Limit user session + * + * Delete older sessions if the number of sessions have crossed + * the session limit set for the project + */ App::shutdown() ->groups(['session']) ->inject('utopia') @@ -326,7 +332,7 @@ App::shutdown() ->inject('project') ->inject('dbForProject') ->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) { - $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS; + $sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT; $session = $response->getPayload(); $userId = $session['userId'] ?? ''; if (empty($userId)) {