From 6bca1cddcda1d19fbd4043af58a9bdcc729a235b Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 16 Oct 2017 19:14:15 -0400 Subject: [PATCH] remember me reimplemented --- app.js | 2 +- routes/login.js | 8 +++++++- views/login.ejs | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 9fe5a38a5..0ad632c7e 100644 --- a/app.js +++ b/app.js @@ -52,7 +52,7 @@ app.use(session({ maxAge: 1800000 }, store: new FileStore({ - ttl: 3600, + ttl: 30 * 24 * 3600, path: '../trilium-data/sessions' }) })); diff --git a/routes/login.js b/routes/login.js index 127440a65..4625ac3d9 100644 --- a/routes/login.js +++ b/routes/login.js @@ -14,9 +14,15 @@ router.post('', async (req, res, next) => { const guessedPassword = req.body.password; if (req.body.username === userName && await verifyPassword(guessedPassword)) { - const rememberMe = req.body.rememberme; + const rememberMe = req.body.remember_me; req.session.regenerate(() => { + if (rememberMe) { + req.session.cookie.maxAge = 21 * 24 * 3600000; // 3 weeks + } else { + req.session.cookie.expires = false; + } + req.session.loggedIn = true; res.redirect('/'); }); diff --git a/views/login.ejs b/views/login.ejs index 70f9e92aa..0c63ac9d5 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -32,7 +32,7 @@