diff --git a/public/src/forum/accountedit.js b/public/src/forum/accountedit.js index 0946362c53..a08ad5a945 100644 --- a/public/src/forum/accountedit.js +++ b/public/src/forum/accountedit.js @@ -107,7 +107,7 @@ $(document).ready(function() { signature:$('#inputSignature').val() }; - socket.emit('api:user.updateProfile', userData, function(data) { + socket.emit('api:user.updateProfile', userData, function(err, data) { if(data.success) { app.alertSuccess('Your profile has been updated successfully!'); if(data.picture) { diff --git a/src/user.js b/src/user.js index ce03af3527..76153692b9 100644 --- a/src/user.js +++ b/src/user.js @@ -224,29 +224,27 @@ var utils = require('./../public/src/utils.js'), async.series([isSignatureValid, isEmailAvailable], function(err, results) { if(err) { - console.log(err); - callback(returnData); + callback(err, returnData); } else { async.each(fields, updateField, function(err) { if(err) { - console.log(err); - callback(returnData); + callback(err, returnData); } else { returnData.success = true; - callback(returnData); + callback(null, returnData); } }); } }); - function updateField(field, callback) { + function updateField(field, next) { if(data[field] !== undefined) { if(field === 'email') { var gravatarpicture = User.createGravatarURLFromEmail(data[field]); User.setUserField(uid, 'gravatarpicture', gravatarpicture); User.getUserFields(uid, ['email', 'picture', 'uploadedpicture'], function(err, userData) { if(err) - return callback(err); + return next(err); RDB.del('email:' + userData['email'] + ':uid'); RDB.set('email:' + data['email'] + ':uid', uid); @@ -256,7 +254,7 @@ var utils = require('./../public/src/utils.js'), User.setUserField(uid, 'picture', gravatarpicture); } returnData.gravatarpicture = gravatarpicture; - callback(null); + next(null); }); return; } else if(field === 'signature') { @@ -265,9 +263,9 @@ var utils = require('./../public/src/utils.js'), User.setUserField(uid, field, data[field]); - callback(null); + next(null); } else { - callback(null); + next(null); } } }