fix: no relative path needed in req.session.returnTo

re: julianlam/nodebb-plugin-session-sharing#73
v1.18.x
Julian Lam 6 years ago
parent d5ece9a4c3
commit 949b10f132

@ -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');
}
});

@ -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({});

Loading…
Cancel
Save