barisusakli 11 years ago
parent b604a4961c
commit d25300043c

@ -13,8 +13,6 @@ var async = require('async'),
module.exports = function(User) { module.exports = function(User) {
User.create = function(userData, callback) { User.create = function(userData, callback) {
var customFields = {};
userData = userData || {}; userData = userData || {};
userData.userslug = utils.slugify(userData.username); userData.userslug = utils.slugify(userData.username);
@ -86,30 +84,20 @@ module.exports = function(User) {
} }
}, },
customFields: function(next) { customFields: function(next) {
plugins.fireHook('filter:user.custom_fields', userData, function(err, fields) { plugins.fireHook('filter:user.custom_fields', userData, next);
if (err) {
return next(err);
}
delete fields.username;
delete fields.userslug;
customFields = fields;
next(err);
});
}, },
userData: function(next) { userData: function(next) {
plugins.fireHook('filter:user.create', userData, function(err, filteredUserData){ plugins.fireHook('filter:user.create', userData, next);
next(err, utils.merge(userData, filteredUserData));
});
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
userData = results.userData; userData = utils.merge(results.userData, results.customFields);
var userNameChanged = !!results.renamedUsername; var userNameChanged = !!results.renamedUsername;
// If a new username was picked...
if (userNameChanged) { if (userNameChanged) {
userData.username = results.renamedUsername; userData.username = results.renamedUsername;
userData.userslug = utils.slugify(results.renamedUsername); userData.userslug = utils.slugify(results.renamedUsername);
@ -123,7 +111,7 @@ module.exports = function(User) {
var gravatar = User.createGravatarURLFromEmail(userData.email); var gravatar = User.createGravatarURLFromEmail(userData.email);
var timestamp = Date.now(); var timestamp = Date.now();
userData = { userData = utils.merge({
'uid': uid, 'uid': uid,
'username': userData.username, 'username': userData.username,
'userslug': userData.userslug, 'userslug': userData.userslug,
@ -143,9 +131,7 @@ module.exports = function(User) {
'lastposttime': 0, 'lastposttime': 0,
'banned': 0, 'banned': 0,
'status': 'online' 'status': 'online'
}; }, userData);
userData = utils.merge(userData, customFields);
db.setObject('user:' + uid, userData, function(err) { db.setObject('user:' + uid, userData, function(err) {
if(err) { if(err) {

Loading…
Cancel
Save