From 3ae9cc767e51657486d1dcd9d6aa90726fb1bbff Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sun, 2 Jul 2017 15:12:09 +0200 Subject: [PATCH] Fixed referring url on private pages --- routes/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/routes/index.js b/routes/index.js index ea761f1e..ec7f7000 100644 --- a/routes/index.js +++ b/routes/index.js @@ -204,7 +204,7 @@ router.get('/' + config.settings.route_name + '/:id', common.restrict, function } // if article is set to private, redirect to login - if(typeof result.faq_visible_state !== 'undefined' && result.faq_visible_state === 'private'){ + if(typeof result.kb_visible_state !== 'undefined' && result.kb_visible_state === 'private'){ if(!req.session.user){ req.session.refer_url = req.originalUrl; res.redirect('/login'); @@ -968,9 +968,16 @@ router.get('/login', function (req, res){ if(user_count > 0){ // set needs_setup to false as a user exists req.session.needs_setup = false; + + // set the referring url + var referringUrl = req.header('Referer'); + if(typeof req.session.refer_url !== 'undefined' && req.session.refer_url !== ''){ + referringUrl = req.session.refer_url; + } + res.render('login', { title: 'Login', - referring_url: req.header('Referer'), + referring_url: referringUrl, config: config, message: common.clear_session_value(req.session, 'message'), message_type: common.clear_session_value(req.session, 'message_type'),