From 7dc9fd83c1ff8405b8f3f16c31fc6fa458ba1abf Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 3 May 2013 12:27:07 -0400 Subject: [PATCH] account page shows up when logged in and 403 when logged out --- public/templates/account.tpl | 18 ++++++++++++++++++ public/templates/header.tpl | 2 +- src/templates.js | 2 +- src/webserver.js | 15 +++++---------- 4 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 public/templates/account.tpl diff --git a/public/templates/account.tpl b/public/templates/account.tpl new file mode 100644 index 0000000000..0a66dc2040 --- /dev/null +++ b/public/templates/account.tpl @@ -0,0 +1,18 @@ +

Account Settings

+
+ +
+ +

+ If you see this, you are logged in. +

+
+ \ No newline at end of file diff --git a/public/templates/header.tpl b/public/templates/header.tpl index 2068576586..def57eaed5 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -30,7 +30,7 @@
  • Forum
  • diff --git a/src/templates.js b/src/templates.js index e56f09f39d..17b41592d7 100644 --- a/src/templates.js +++ b/src/templates.js @@ -25,7 +25,7 @@ Templates.init = function() { loadTemplates([ - 'header', 'footer', 'register', 'home', 'topic', + 'header', 'footer', 'register', 'home', 'topic', 'account', 'login', 'reset', 'reset_code', 'logout', '403', 'emails/reset', 'emails/reset_plaintext' diff --git a/src/webserver.js b/src/webserver.js index b9941dfd58..3b63f9d363 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -78,14 +78,6 @@ passport.deserializeUser(function(uid, done) { (function(app) { var templates = global.templates; - function refreshTemplates() { - //need a better solution than copying this code on every call. is there an "onconnect" event? - if (DEVELOPMENT === true) { - // refreshing templates - modules.templates.init(); - } - } - // Middlewares app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc) app.use(require('less-middleware')({ src: path.join(__dirname, '../', '/public') })); @@ -259,8 +251,11 @@ passport.deserializeUser(function(uid, done) { }); app.get('/account', function(req, res) { - refreshTemplates(); - res.send(templates['header'] + templates['account_settings'] + templates['footer']); + + if (req.user === undefined) + return res.redirect('/403'); + + res.send(templates['header'] + templates['account'] + templates['footer']); }); app.get('/users', function(req, res) {