remember me reimplemented

This commit is contained in:
azivner 2017-10-16 19:14:15 -04:00
parent a13b4a6f7e
commit 6bca1cddcd
3 changed files with 9 additions and 3 deletions

2
app.js
View file

@ -52,7 +52,7 @@ app.use(session({
maxAge: 1800000
},
store: new FileStore({
ttl: 3600,
ttl: 30 * 24 * 3600,
path: '../trilium-data/sessions'
})
}));

View file

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

View file

@ -32,7 +32,7 @@
<div class="form-group">
<div class="checkbox">
<label>
<input id="remember-me" name="remember-me" value="1" type="checkbox"> Remember me
<input id="remember-me" name="remember_me" value="1" type="checkbox"> Remember me
</label>
</div>
</div>