From c4b083330c7d22edfc59e711b0f2d3c1bfc9c260 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 11 Aug 2014 18:07:56 -0400 Subject: [PATCH] closes #1978 --- src/user/create.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/user/create.js b/src/user/create.js index ede0202b2b..80a5877d7f 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -12,14 +12,14 @@ var async = require('async'), module.exports = function(User) { - User.create = function(userData, callback) { - var gravatar = User.createGravatarURLFromEmail(userData.email); + User.create = function(data, callback) { + var gravatar = User.createGravatarURLFromEmail(data.email); var timestamp = Date.now(); - var password = userData.password; + var password = data.password; - userData = { - 'username': userData.username.trim(), - 'email': userData.email, + var userData = { + 'username': data.username.trim(), + 'email': data.email, 'joindate': timestamp, 'picture': gravatar, 'gravatarpicture': gravatar, @@ -103,7 +103,7 @@ module.exports = function(User) { } }, customFields: function(next) { - plugins.fireHook('filter:user.custom_fields', userData, next); + plugins.fireHook('filter:user.custom_fields', [], next); }, userData: function(next) { plugins.fireHook('filter:user.create', userData, next); @@ -113,7 +113,14 @@ module.exports = function(User) { return callback(err); } - userData = utils.merge(results.userData, results.customFields); + var customData = {}; + results.customFields.forEach(function(customField) { + if (data[customField]) { + customData[customField] = data[customField]; + } + }); + + userData = utils.merge(results.userData, customData); var userNameChanged = !!results.renamedUsername;