mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2025-12-06 09:44:06 +00:00
session cookie cleared on client side for logout/deauth
This commit is contained in:
parent
143391507e
commit
2225f5db49
@ -135,10 +135,12 @@ const logout = async (req, res) => {
|
||||
const delSession = req.session.destroy((err) => {
|
||||
if (Object.keys(err).length) {
|
||||
logger.error("Error while logging out", { err });
|
||||
return res.sendStatus(500);
|
||||
} else {
|
||||
logger.info("Logged out.", { sessionID: delSession.id });
|
||||
res.clearCookie("connect.sid");
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
return res.sendStatus(200);
|
||||
})
|
||||
} catch (error) {
|
||||
logger.error('logout', { error });
|
||||
|
||||
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user