Skip to content

Node.js based forum software built for the modern web

fix(auth): clear session info when switching users in doLogin

Julian Lamb88fe35a3d69
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index c388023840..74b4e8b5ae 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -320,7 +320,8 @@ authenticationController.doLogin = async function (req, uid) {
return;
}
const loginAsync = util.promisify(req.login).bind(req);
- await loginAsync({ uid: uid }, { keepSessionInfo: req.res.locals.reroll !== false });
+ const keepSessionInfo = (req?.res?.locals?.reroll !== false) && uid === req.uid;
+ await loginAsync({ uid: uid }, { keepSessionInfo });
await authenticationController.onSuccessfulLogin(req, uid);
};