-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Seeing as we're requiring a bunch of modules already and just calling functions in server.js, it might be better to also do the same with the sessions function.
function sessions(req, res, next) {
const sid = req.signedCookies.sid; //undefined if there is not a sid
const session = getSession(sid); //undefined if there is no session
if (session) {
const expiry = new Date(session.expires_at);
const today = new Date();
if (expiry < today) {
removeSession(sid);
res.clearCookie('sid');
} else {
req.session = session;
}
}
next();
}Metadata
Metadata
Assignees
Labels
No labels