diff --git a/src/groups/data.js b/src/groups/data.js index 21a5db4b56..19a1119b8e 100644 --- a/src/groups/data.js +++ b/src/groups/data.js @@ -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; diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js index e468125b27..7b8e383a85 100644 --- a/src/socket.io/groups.js +++ b/src/socket.io/groups.js @@ -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]]'); } }