mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-02 05:00:40 +08:00
feat(login): make use of default maxAge by sessionParser
cookie will use the default value set in sessionParser middleware, which is controlled by config.Session.cookieMaxAge if rememberMe is not set -> the value is unset and the cookie becomes a non-persistent cookie, which the browser delete after the current session (e.g. when you close the browser)
This commit is contained in:
parent
2a740781cb
commit
38215c46ae
@ -70,9 +70,12 @@ function login(req: Request, res: Response) {
|
||||
}
|
||||
|
||||
req.session.regenerate(() => {
|
||||
const sessionMaxAge = 21 * 24 * 3600000 // 3 weeks in Milliseconds
|
||||
if (!rememberMe) {
|
||||
// unset default maxAge set by sessionParser
|
||||
// Cookie becomes non-persistent and expires after current browser session (e.g. when browser is closed)
|
||||
req.session.cookie.maxAge = undefined;
|
||||
}
|
||||
|
||||
req.session.cookie.maxAge = (rememberMe) ? sessionMaxAge : undefined;
|
||||
req.session.loggedIn = true;
|
||||
|
||||
res.redirect(".");
|
||||
|
Loading…
x
Reference in New Issue
Block a user