Skip to content

Node.js based forum software built for the modern web

closes #3961

barisusaklie067d26ca365
diff --git a/src/groups/update.js b/src/groups/update.js
index b239df39de..0ac688aca0 100644
--- a/src/groups/update.js
+++ b/src/groups/update.js
@@ -45,6 +45,7 @@ module.exports = function(Groups) {
}
async.series([
+ async.apply(checkNameChange, groupName, values.name),
async.apply(updatePrivacy, groupName, values.private),
function(next) {
if (values.hasOwnProperty('hidden')) {
@@ -217,6 +218,23 @@ module.exports = function(Groups) {
});
}
+ function checkNameChange(oldName, newName, callback) {
+ if (oldName === newName) {
+ return callback();
+ }
+ var oldSlug = utils.slugify(oldName);
+ var newSlug = utils.slugify(newName);
+ if (oldSlug === newSlug) {
+ return callback();
+ }
+ Groups.existsBySlug(newSlug, function(err, exists) {
+ if (err || exists) {
+ return callback(err || new Error('[[error:group-already-exists]]'));
+ }
+ callback();
+ });
+ }
+
function renameGroup(oldName, newName, callback) {
if (oldName === newName || !newName || newName.length === 0) {
return callback();