mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 01:21:13 +01:00
fix: log out user if session cookie resolves to non-existent uid
This commit is contained in:
@@ -490,7 +490,7 @@ authenticationController.logout = async function (req, res) {
|
|||||||
};
|
};
|
||||||
await plugins.hooks.fire('filter:user.logout', payload);
|
await plugins.hooks.fire('filter:user.logout', payload);
|
||||||
|
|
||||||
if (req.body?.noscript === 'true') {
|
if (req.body?.noscript === 'true' || res.locals.logoutRedirect === true) {
|
||||||
return res.redirect(payload.next);
|
return res.redirect(payload.next);
|
||||||
}
|
}
|
||||||
res.status(200).send(payload);
|
res.status(200).send(payload);
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ module.exports = function (middleware) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (req.loggedIn) {
|
if (req.loggedIn) {
|
||||||
|
const exists = await user.exists(req.uid);
|
||||||
|
if (!exists) {
|
||||||
|
res.locals.logoutRedirect = true;
|
||||||
|
return controllers.authentication.logout(req, res);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (req.headers.hasOwnProperty('authorization')) {
|
} else if (req.headers.hasOwnProperty('authorization')) {
|
||||||
const user = await passportAuthenticateAsync(req, res);
|
const user = await passportAuthenticateAsync(req, res);
|
||||||
|
|||||||
Reference in New Issue
Block a user