mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
added additional visibility masks for profile menu hook, also added isPrivileged user method, closes #5306
This commit is contained in:
@@ -73,6 +73,30 @@ middleware.ensureSelfOrGlobalPrivilege = function (req, res, next) {
|
||||
}
|
||||
};
|
||||
|
||||
middleware.ensureSelfOrPrivileged = function (req, res, next) {
|
||||
/*
|
||||
The "self" part of this middleware hinges on you having used
|
||||
middleware.exposeUid prior to invoking this middleware.
|
||||
*/
|
||||
if (req.user) {
|
||||
if (req.user.uid === res.locals.uid) {
|
||||
return next();
|
||||
}
|
||||
|
||||
user.isPrivileged(req.uid, function (err, ok) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
} else if (ok) {
|
||||
return next();
|
||||
} else {
|
||||
controllers.helpers.notAllowed(req, res);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
controllers.helpers.notAllowed(req, res);
|
||||
}
|
||||
};
|
||||
|
||||
middleware.pageView = function (req, res, next) {
|
||||
analytics.pageView({
|
||||
ip: req.ip,
|
||||
|
||||
Reference in New Issue
Block a user