v1.18.x
barisusakli 10 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)) {
if (!req.user) {
return render();
} else {
user.isAdministrator(req.user.uid, function(err, isAdmin) {
if (!isAdmin) {
return render();
} else {
return next();
}
});
}
} else {
return next(); return next();
} }
if (!req.user) {
return render();
}
user.isAdministrator(req.user.uid, function(err, isAdmin) {
if (err) {
return next(err);
}
if (!isAdmin) {
render();
} else {
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