Barış Soner Uşaklı 7 years ago
parent d42ffdae77
commit 9132743870

@ -168,7 +168,7 @@ module.exports = function (Groups) {
function (next) {
async.parallel({
group: function (next) {
db.getObject('group:' + currentName, next);
Groups.getGroupData(currentName, next);
},
exists: function (next) {
Groups.existsBySlug(newSlug, next);
@ -180,7 +180,11 @@ module.exports = function (Groups) {
return next(new Error('[[error:group-already-exists]]'));
}
if (parseInt(results.group.system, 10) === 1) {
if (!results.group) {
return next(new Error('[[error:no-group]]'));
}
if (results.group.system) {
return next(new Error('[[error:not-allowed-to-rename-system-group]]'));
}

@ -238,6 +238,7 @@ SocketGroups.create = function (socket, data, callback) {
SocketGroups.delete = isOwner(function (socket, data, callback) {
if (data.groupName === 'administrators' ||
data.groupName === 'registered-users' ||
data.groupName === 'guests' ||
data.groupName === 'Global Moderators') {
return callback(new Error('[[error:not-allowed]]'));
}

@ -942,6 +942,19 @@ describe('Groups', function () {
});
});
it('should fail to rename guests group', function (done) {
var data = {
groupName: 'guests',
values: {
name: 'guests2',
},
};
socketGroups.update({ uid: adminUid }, data, function (err) {
assert.equal(err.message, '[[error:no-group]]');
done();
});
});
it('should delete group', function (done) {
socketGroups.delete({ uid: adminUid }, { groupName: 'renamedupdategroup' }, function (err) {
assert.ifError(err);
@ -974,6 +987,13 @@ describe('Groups', function () {
});
});
it('should fail to delete group if name is special', function (done) {
socketGroups.delete({ uid: adminUid }, { groupName: 'guests' }, function (err) {
assert.equal(err.message, '[[error:not-allowed]]');
done();
});
});
it('should fail to load more groups with invalid data', function (done) {
socketGroups.loadMore({ uid: adminUid }, {}, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');

Loading…
Cancel
Save