fixed broken mget implementation if no topics are present

This commit is contained in:
Julian Lam
2013-04-24 22:20:05 -04:00
parent a16f72e11c
commit 9e5a7b96b3
3 changed files with 41 additions and 29 deletions

View File

@@ -15,9 +15,16 @@ var express = require('express'),
}
}
function checkAuth(req, res, next) {
function hasAuth(req, res, next) {
// Include this middleware if the endpoint is publically accessible, but has elements that logged in users can see
}
function requireAuth(req, res, next) {
// Include this middleware if the endpoint requires a logged in user to view
console.log('REQUIRE: ', global.uid, req.sessionID);
if (!global.uid) {
res.send(403, 'You are not authorized to view this page');
req.redirect('/403');
} else {
next();
}
@@ -63,11 +70,15 @@ var express = require('express'),
res.send(templates['header'] + templates['register'] + templates['footer']);
});
app.get('/account', checkAuth, function(req, res) {
app.get('/account', requireAuth, function(req, res) {
refreshTemplates();
res.send(templates['header'] + templates['account_settings'] + templates['footer']);
});
app.get('/403', function(req, res) {
res.send(403, 'You are not authorized to view this page');
});
module.exports.init = function() {
// todo move some of this stuff into config.json
app.configure(function() {