From 366ad5cd6972b8f405e63b6da5b42b93a9247fd4 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Tue, 19 Nov 2019 12:02:14 -0500 Subject: [PATCH] fix: #8050, fix redirect after registration --- src/controllers/authentication.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 11776c510c..aa1683305c 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -34,6 +34,9 @@ async function registerAndLoginUser(req, res, userData) { userData.register = true; req.session.registration = userData; + if (req.body.referrer) { + req.session.referrer = req.body.referrer; + } if (req.body.noscript === 'true') { res.redirect(nconf.get('relative_path') + '/register/complete'); return; @@ -53,7 +56,10 @@ async function registerAndLoginUser(req, res, userData) { } user.deleteInvitationKey(userData.email); - return await plugins.fireHook('filter:register.complete', { uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/' }); + const referrer = req.body.referrer || req.session.referrer || nconf.get('relative_path') + '/'; + const complete = await plugins.fireHook('filter:register.complete', { uid: uid, referrer: referrer }); + req.session.returnTo = complete.referrer; + return complete; } const registerAndLoginUserCallback = util.callbackify(registerAndLoginUser);