Auto-extend session if loading the home page
This commit is contained in:
parent
1a372abaff
commit
b340863d52
|
@ -14,6 +14,7 @@ declare global {
|
||||||
declare module 'express-session' {
|
declare module 'express-session' {
|
||||||
export interface SessionData {
|
export interface SessionData {
|
||||||
handle: string;
|
handle: string;
|
||||||
|
touch: number;
|
||||||
// other properties...
|
// other properties...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,6 +559,12 @@ async function setUserDataMiddleware(request, response, next) {
|
||||||
profile: user,
|
profile: user,
|
||||||
directories: directories,
|
directories: directories,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Touch the session if loading the home page
|
||||||
|
if (request.method === 'GET' && request.path === '/') {
|
||||||
|
request.session.touch = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue