v1.18.x
Barış Soner Uşaklı 5 years ago
parent 1e50616c13
commit c35a21d7f0

@ -53,6 +53,11 @@ module.exports = function (Groups) {
return Array.isArray(groupsData) && groupsData[0] ? groupsData[0] : null;
};
Groups.getGroupField = async function (groupName, field) {
const groupData = await Groups.getGroupFields(groupName, [field]);
return groupData ? groupData[field] : null;
};
Groups.getGroupFields = async function (groupName, fields) {
const groups = await Groups.getGroupsFields([groupName], fields);
return groups ? groups[0] : null;

@ -375,10 +375,12 @@ async function canModifyGroup(uid, groupName) {
}
const results = await utils.promiseParallel({
isOwner: groups.ownership.isOwner(uid, groupName),
isAdminOrGlobalMod: user.isAdminOrGlobalMod(uid),
system: groups.getGroupField(groupName, 'system'),
isAdmin: user.isAdministrator(uid),
isGlobalMod: user.isGlobalModerator(uid),
});
if (!results.isOwner && !results.isAdminOrGlobalMod) {
if (!(results.isOwner || results.isAdmin || (results.isGlobalMod && !results.system))) {
throw new Error('[[error:no-privileges]]');
}
}

Loading…
Cancel
Save