From 39f12e215a5a45301bbb93203d424fd2cb638cd2 Mon Sep 17 00:00:00 2001 From: Bruno Bernardino Date: Fri, 14 Apr 2023 09:06:26 +0100 Subject: [PATCH] Extend the session when there's a valid interaction. --- lib/data-utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/data-utils.ts b/lib/data-utils.ts index 53e0210..91a17f6 100644 --- a/lib/data-utils.ts +++ b/lib/data-utils.ts @@ -183,7 +183,10 @@ export async function validateUserAndSession(userId: string, sessionId: string, throw new Error('Not Found'); } + const oneMonthFromToday = new Date(new Date().setUTCMonth(new Date().getUTCMonth() + 1)); + session.last_seen_at = new Date(); + session.expires_at = oneMonthFromToday; await updateSession(session);