mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 14:14:06 +00:00
session cookie cleared on client side for logout/deauth
This commit is contained in:
@@ -13,12 +13,14 @@ const isAuthenticated = (req, res, next) => {
|
||||
next()
|
||||
} else {
|
||||
const delSession = req.session.destroy((err) => {
|
||||
if (err) {
|
||||
if (Object.keys(err).length) {
|
||||
logger.error("Error while destroying session.", { err });
|
||||
return res.status(500).send("Server error, try later.");
|
||||
} else {
|
||||
logger.info("Session destroyed.", { sessionID: delSession.id });
|
||||
logger.info("Session invalid, destroyed.", { sessionID: delSession.id });
|
||||
res.clearCookie("connect.sid");
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
return res.sendStatus(401);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user