From 2930892aa7d613deadd0a9012b816794e5da044c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 24 Aug 2023 21:29:26 -0400 Subject: [PATCH] pass req.query.next to sso callback user req.query.next instead of req.session.returnTo if it exists --- src/routes/authentication.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index e24ff064b9..9d89df90e1 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -97,6 +97,9 @@ Auth.reloadRoutes = async function (params) { req.session.ssoState = generateToken(req, true); opts.state = req.session.ssoState; } + if (req.query.next) { + req.session.next = req.query.next; + } // Allow SSO plugins to override/append options (for use in passport prototype authorizationParams) ({ opts } = await plugins.hooks.fire('filter:auth.options', { req, res, opts })); @@ -116,7 +119,7 @@ Auth.reloadRoutes = async function (params) { req.session.registration = req.session.registration || {}; // save returnTo for later usage in /register/complete // passport seems to remove `req.session.returnTo` after it redirects - req.session.registration.returnTo = req.session.returnTo; + req.session.registration.returnTo = req.session.next || req.session.returnTo; passport.authenticate(strategy.name, (err, user) => { if (err) {