mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-08 12:23:35 +02:00
closes #3581
This commit is contained in:
@@ -7,16 +7,16 @@ var async = require('async'),
|
||||
db = require('../database');
|
||||
|
||||
module.exports = function(Groups) {
|
||||
Groups.create = function(data, callback) {
|
||||
if (data.name.length === 0) {
|
||||
return callback(new Error('[[error:group-name-too-short]]'));
|
||||
}
|
||||
|
||||
Groups.create = function(data, callback) {
|
||||
var system = data.name === 'administrators' || data.name === 'registered-users' || Groups.isPrivilegeGroup(data.name);
|
||||
var groupData;
|
||||
var timestamp = data.timestamp || Date.now();
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
validateGroupName(data.name, next);
|
||||
},
|
||||
function (next) {
|
||||
meta.userOrGroupExists(data.name, next);
|
||||
},
|
||||
@@ -71,4 +71,14 @@ module.exports = function(Groups) {
|
||||
], callback);
|
||||
|
||||
};
|
||||
|
||||
function validateGroupName(name, callback) {
|
||||
if (!name) {
|
||||
return callback(new Error('[[error:group-name-too-short]]'));
|
||||
}
|
||||
|
||||
if (name.indexOf('/') !== -1) {
|
||||
return callback(new Error('[[error:invalid-group-name]]'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user