mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
async
This commit is contained in:
@@ -126,33 +126,30 @@ middleware.checkGlobalPrivacySettings = function(req, res, next) {
|
|||||||
|
|
||||||
middleware.checkAccountPermissions = function(req, res, next) {
|
middleware.checkAccountPermissions = function(req, res, next) {
|
||||||
// This middleware ensures that only the requested user and admins can pass
|
// This middleware ensures that only the requested user and admins can pass
|
||||||
middleware.authenticate(req, res, function(err) {
|
async.waterfall([
|
||||||
if (err) {
|
function (next) {
|
||||||
return next(err);
|
middleware.authenticate(req, res, next);
|
||||||
}
|
},
|
||||||
|
function (next) {
|
||||||
user.getUidByUserslug(req.params.userslug, function (err, uid) {
|
user.getUidByUserslug(req.params.userslug, next);
|
||||||
if (err) {
|
},
|
||||||
return next(err);
|
function (uid, next) {
|
||||||
}
|
|
||||||
|
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
return controllers.helpers.notFound(req, res);
|
return controllers.helpers.notFound(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(uid, 10) === req.uid) {
|
if (parseInt(uid, 10) === req.uid) {
|
||||||
return next();
|
return next(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.isAdministrator(req.uid, function(err, isAdmin) {
|
user.isAdministrator(req.uid, next);
|
||||||
if (err || isAdmin) {
|
}
|
||||||
|
], function (err, allowed) {
|
||||||
|
if (err || allowed) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
controllers.helpers.notAllowed(req, res);
|
controllers.helpers.notAllowed(req, res);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.isAdmin = function(req, res, next) {
|
middleware.isAdmin = function(req, res, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user