mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #7240
This commit is contained in:
@@ -325,13 +325,9 @@ SocketGroups.cover.update = function (socket, data, callback) {
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
groups.ownership.isOwner(socket.uid, data.groupName, next);
|
canModifyGroup(socket.uid, data.groupName, next);
|
||||||
},
|
},
|
||||||
function (isOwner, next) {
|
function (next) {
|
||||||
if (!isOwner) {
|
|
||||||
return next(new Error('[[error:no-privileges]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
groups.updateCover(socket.uid, data, next);
|
groups.updateCover(socket.uid, data, next);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
@@ -344,14 +340,27 @@ SocketGroups.cover.remove = function (socket, data, callback) {
|
|||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
groups.ownership.isOwner(socket.uid, data.groupName, next);
|
canModifyGroup(socket.uid, data.groupName, next);
|
||||||
},
|
},
|
||||||
function (isOwner, next) {
|
function (next) {
|
||||||
if (!isOwner) {
|
|
||||||
return next(new Error('[[error:no-privileges]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
groups.removeCover(data, next);
|
groups.removeCover(data, next);
|
||||||
},
|
},
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function canModifyGroup(uid, groupName, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
async.parallel({
|
||||||
|
isOwner: async.apply(groups.ownership.isOwner, uid, groupName),
|
||||||
|
isAdminOrGlobalMod: async.apply(user.isAdminOrGlobalMod, uid),
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (results, next) {
|
||||||
|
if (!results.isOwner && !results.isAdminOrGlobalMod) {
|
||||||
|
return next(new Error('[[error:no-privileges]]'));
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
], callback);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user