Skip to content

Node.js based forum software built for the modern web

fix email update on mongo

barisusakli1b80e6dbb273
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);