From e0aeeba1174408d1603791085399672484f305e0 Mon Sep 17 00:00:00 2001 From: Taly Date: Mon, 27 Jul 2020 17:13:17 +0300 Subject: [PATCH] Set auth cookie lifetime --- src/routes/auth.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/auth.js b/src/routes/auth.js index 601c24f..b189387 100644 --- a/src/routes/auth.js +++ b/src/routes/auth.js @@ -51,7 +51,10 @@ router.post('/auth', parseForm, csrfProtection, async (req, res) => { iat: Date.now(), }, passHash + config.secret); - res.cookie('authToken', token, { httpOnly: true }); + res.cookie('authToken', token, { + httpOnly: true, + expires: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000) // 1 year + }); res.redirect('/'); });