v1.18.x
barisusakli 11 years ago
parent 0305ad989c
commit 2974f1ba8a

@ -445,7 +445,7 @@ middleware.addExpiresHeaders = function(req, res, next) {
}; };
middleware.maintenanceMode = function(req, res, next) { middleware.maintenanceMode = function(req, res, next) {
if (meta.config.maintenanceMode !== '1') { if (parseInt(meta.config.maintenanceMode, 10) !== 1) {
return next(); return next();
} }
@ -480,35 +480,35 @@ middleware.maintenanceMode = function(req, res, next) {
return true; return true;
} }
} }
return false;
}, },
isApiRoute = /^\/api/; isApiRoute = /^\/api/;
if (!isAllowed(req.url)) { if (isAllowed(req.url)) {
return next();
}
if (!req.user) { if (!req.user) {
return render(); return render();
} else { }
user.isAdministrator(req.user.uid, function(err, isAdmin) { user.isAdministrator(req.user.uid, function(err, isAdmin) {
if (err) {
return next(err);
}
if (!isAdmin) { if (!isAdmin) {
return render(); render();
} else { } else {
return next(); next();
} }
}); });
}
} else {
return next();
}
}; };
middleware.publicTagListing = function(req, res, next) { middleware.publicTagListing = function(req, res, next) {
if ((!meta.config.hasOwnProperty('publicTagListing') || parseInt(meta.config.publicTagListing, 10) === 1)) { if (req.user || (!meta.config.hasOwnProperty('publicTagListing') || parseInt(meta.config.publicTagListing, 10) === 1)) {
next(); next();
} else { } else {
if (res.locals.isAPI) { controllers.helpers.notAllowed(req, res);
res.sendStatus(401);
} else {
middleware.ensureLoggedIn(req, res, next);
}
} }
}; };

Loading…
Cancel
Save