return err form updateProfile

v1.18.x
Baris Usakli 12 years ago
parent be51025048
commit 251587cb86

@ -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) {

@ -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);
}
}
}

Loading…
Cancel
Save