From 949b10f132bbea7900048b993122629b7bfc227f Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 15 Feb 2019 16:41:49 -0500 Subject: [PATCH] fix: no relative path needed in req.session.returnTo re: julianlam/nodebb-plugin-session-sharing#73 --- src/controllers/helpers.js | 4 ++-- src/middleware/user.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 6068de3091..efdf97e811 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -136,10 +136,10 @@ helpers.notAllowed = function (req, res, error) { }); } } else if (res.locals.isAPI) { - req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); + req.session.returnTo = req.url.replace(/^\/api/, ''); res.status(401).json('not-authorized'); } else { - req.session.returnTo = nconf.get('relative_path') + req.url; + req.session.returnTo = req.url; res.redirect(nconf.get('relative_path') + '/login'); } }); diff --git a/src/middleware/user.js b/src/middleware/user.js index 86cb998332..f43319e1dd 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -229,7 +229,7 @@ module.exports = function (middleware) { } returnTo = returnTo.replace(/^\/api/, ''); - req.session.returnTo = nconf.get('relative_path') + returnTo; + req.session.returnTo = returnTo; req.session.forceLogin = 1; if (res.locals.isAPI) { res.status(401).json({});