|
|
@ -46,7 +46,7 @@ module.exports = function (User) {
|
|
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
async.parallel({
|
|
|
|
renamedUsername: function (next) {
|
|
|
|
renamedUsername: function (next) {
|
|
|
|
renameUsername(userData, next);
|
|
|
|
User.renameUsername(userData, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
userData: function (next) {
|
|
|
|
userData: function (next) {
|
|
|
|
plugins.fireHook('filter:user.create', { user: userData, data: data }, next);
|
|
|
|
plugins.fireHook('filter:user.create', { user: userData, data: data }, next);
|
|
|
@ -200,28 +200,28 @@ module.exports = function (User) {
|
|
|
|
callback();
|
|
|
|
callback();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function renameUsername(userData, callback) {
|
|
|
|
User.renameUsername = function (userData, callback) {
|
|
|
|
meta.userOrGroupExists(userData.userslug, function (err, exists) {
|
|
|
|
meta.userOrGroupExists(userData.userslug, function (err, exists) {
|
|
|
|
if (err || !exists) {
|
|
|
|
if (err || !exists) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var newUsername = '';
|
|
|
|
var num = 0;
|
|
|
|
async.forever(function (next) {
|
|
|
|
|
|
|
|
newUsername = userData.username + (Math.floor(Math.random() * 255) + 1);
|
|
|
|
function go() {
|
|
|
|
User.existsBySlug(newUsername, function (err, exists) {
|
|
|
|
var username = userData.username + ' ' + num.toString(32);
|
|
|
|
if (err) {
|
|
|
|
var userslug = utils.slugify(username);
|
|
|
|
return callback(err);
|
|
|
|
meta.userOrGroupExists(userslug, function (err, exists) {
|
|
|
|
}
|
|
|
|
if (err || !exists) {
|
|
|
|
if (!exists) {
|
|
|
|
return callback(err, username);
|
|
|
|
next(newUsername);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
num += 1;
|
|
|
|
|
|
|
|
go();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, function (username) {
|
|
|
|
}
|
|
|
|
callback(null, username);
|
|
|
|
|
|
|
|
});
|
|
|
|
go();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|