mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +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);
|
||||
|
||||
if (req.body?.noscript === 'true') {
|
||||
if (req.body?.noscript === 'true' || res.locals.logoutRedirect === true) {
|
||||
return res.redirect(payload.next);
|
||||
}
|
||||
res.status(200).send(payload);
|
||||
|
||||
@@ -53,6 +53,12 @@ module.exports = function (middleware) {
|
||||
}
|
||||
|
||||
if (req.loggedIn) {
|
||||
const exists = await user.exists(req.uid);
|
||||
if (!exists) {
|
||||
res.locals.logoutRedirect = true;
|
||||
return controllers.authentication.logout(req, res);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (req.headers.hasOwnProperty('authorization')) {
|
||||
const user = await passportAuthenticateAsync(req, res);
|
||||
|
||||
Reference in New Issue
Block a user