From 12e8423a2464624bcddad3ddf3030f7ea7c12b78 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 25 Jul 2013 14:04:00 -0400 Subject: [PATCH] closed #132 - issue where all auth routes were not rendering the header properly --- src/routes/authentication.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 19ac5345df..ecdf8972fe 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -84,13 +84,15 @@ Auth.create_routes = function(app) { app.get('/logout', function(req, res) { - console.log('info: [Auth] Session ' + req.sessionID + ' logout (uid: ' + global.uid + ')'); - login_module.logout(req.sessionID, function(logout) { - req.logout(); - app.build_header({ req: req, res: res }, function(header) { - res.send(header + templates['logout'] + templates['footer']); + if (req.user && req.user.uid > 0) { + console.log('info: [Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')'); + login_module.logout(req.sessionID, function(logout) { + req.logout(); + app.build_header({ req: req, res: res }, function(err, header) { + res.send(header + templates['logout'] + templates['footer']); + }); }); - }); + } else res.redirect('/'); }); if (login_strategies.indexOf('twitter') !== -1) { @@ -123,13 +125,14 @@ app.get('/reset/:code', function(req, res) { - app.build_header({ req: req, res: res }, function(header) { + app.build_header({ req: req, res: res }, function(err, header) { res.send(header + templates['reset_code'].parse({ reset_code: req.params.code }) + templates['footer']); }); }); app.get('/reset', function(req, res) { - app.build_header({ req: req, res: res }, function(header) { + app.build_header({ req: req, res: res }, function(err, header) { + console.log(header); res.send(header + templates['reset'] + templates['footer']); }); });