From 1b80e6dbb2730ba35e3d59f1438af74ae1862c9b Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 21 Oct 2014 14:17:30 -0400 Subject: [PATCH] fix email update on mongo --- src/database/mongo/hash.js | 6 +++++- src/user/profile.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index 43460f421c..b1d04e0ae8 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -17,6 +17,10 @@ module.exports = function(db, module) { }; module.setObjectField = function(key, field, value, callback) { + callback = callback || helpers.noop; + if (!field) { + return callback(); + } var data = {}; field = helpers.fieldToString(field); data[field] = value; @@ -172,7 +176,7 @@ module.exports = function(db, module) { module.deleteObjectField = function(key, field, callback) { callback = callback || helpers.noop; - if (!key) { + if (!key || !field) { return callback(); } var data = {}; diff --git a/src/user/profile.js b/src/user/profile.js index 8b46f53994..8f10481f84 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -148,7 +148,7 @@ module.exports = function(User) { User.setUserField(uid, 'email', newEmail, next); }, function(next) { - if (parseInt(meta.config.requireEmailConfirmation, 10) === 1) { + if (parseInt(meta.config.requireEmailConfirmation, 10) === 1 && newEmail) { User.email.verify(uid, newEmail); } User.setUserField(uid, 'email:confirmed', 0, next);