mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-14 00:07:00 +01:00
fix: persist login sessions across browser restarts
This commit is contained in:
1 parent
91f57879fb
commit
6593319c87
2 files changed
+96
-3
No files matched your search
@@ -165,13 +165,12 @@ passport.deserializeUser(async (id: string, done) => {
|
||||
}
|
||||
});
|
||||
|
||||
export function initSession() {
|
||||
const redisClient = createClient({
|
||||
export function initSession(redisClient = createClient({
|
||||
socket: {
|
||||
port: config.REDIS_PORT,
|
||||
host: config.REDIS_HOSTNAME,
|
||||
},
|
||||
});
|
||||
})) {
|
||||
redisClient.on("error", (err) =>
|
||||
logger.error("redis client error", serializeError(err))
|
||||
);
|
||||
@@ -186,6 +185,14 @@ export function initSession() {
|
||||
store: redisStore,
|
||||
saveUninitialized: false,
|
||||
resave: false,
|
||||
rolling: true,
|
||||
cookie: {
|
||||
// Keep the browser cookie and Redis expiry aligned on active sessions.
|
||||
maxAge: 30 * 24 * 60 * 60 * 1000,
|
||||
httpOnly: true,
|
||||
sameSite: "lax",
|
||||
secure: "auto",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user