Skip to content

Commit

Permalink
Fixed referring url on private pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Moffat committed Jul 2, 2017
1 parent 243633b commit 3ae9cc7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 3ae9cc7

Please sign in to comment.