From 1fee6a702aa23322468bc4b612c05212d252d49a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 14 Apr 2021 16:13:02 -0400 Subject: [PATCH] fix: #9487, session data gathered during a session is lost upon login e.g. returnTo, tids_viewed, etc. --- src/controllers/authentication.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 0542355bb6..f5d44dec36 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -328,7 +328,12 @@ authenticationController.doLogin = async function (req, uid) { const loginAsync = util.promisify(req.login).bind(req); const regenerateSession = util.promisify(req.session.regenerate).bind(req.session); + const sessionData = { ...req.session }; await regenerateSession(); + for (const [prop, value] of Object.entries(sessionData)) { + req.session[prop] = value; + } + await loginAsync({ uid: uid }); await authenticationController.onSuccessfulLogin(req, uid); };