From 89225c80ca7c620547431b677b5cc844f84054d3 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 6 May 2014 13:05:27 -0400 Subject: [PATCH] related to #1493 --- src/middleware/admin.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/middleware/admin.js b/src/middleware/admin.js index e04be5391b..cbe7b2ed16 100644 --- a/src/middleware/admin.js +++ b/src/middleware/admin.js @@ -16,6 +16,10 @@ var app, middleware.isAdmin = function(req, res, next) { user.isAdministrator((req.user && req.user.uid) ? req.user.uid : 0, function (err, isAdmin) { + if (err) { + return next(err); + } + if (!isAdmin) { res.status(403); res.redirect('/403'); @@ -26,6 +30,7 @@ middleware.isAdmin = function(req, res, next) { }; middleware.buildHeader = function(req, res, next) { + var uid = req.user ? req.user.uid : 0; async.parallel([ function(next) { var custom_header = { @@ -33,7 +38,7 @@ middleware.buildHeader = function(req, res, next) { 'authentication': [] }; - user.getUserFields(req.user.uid, ['username', 'userslug', 'picture'], function(err, userData) { + user.getUserFields(uid, ['username', 'userslug', 'picture'], function(err, userData) { async.parallel({ scripts: function(next) { plugins.fireHook('filter:admin.scripts.get', [], function(err, scripts) {