mirror of
https://github.com/zadam/trilium.git
synced 2025-01-30 10:57:51 +08:00
remember me reimplemented
This commit is contained in:
parent
a13b4a6f7e
commit
6bca1cddcd
3 changed files with 9 additions and 3 deletions
2
app.js
2
app.js
|
@ -52,7 +52,7 @@ app.use(session({
|
|||
maxAge: 1800000
|
||||
},
|
||||
store: new FileStore({
|
||||
ttl: 3600,
|
||||
ttl: 30 * 24 * 3600,
|
||||
path: '../trilium-data/sessions'
|
||||
})
|
||||
}));
|
||||
|
|
|
@ -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('/');
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue