handle async flow/errors of profile update

This commit is contained in:
Berkeley Martinez
2015-03-17 21:09:54 -07:00
parent ab14b32d19
commit 3b913be893
2 changed files with 34 additions and 15 deletions

View File

@ -377,9 +377,18 @@ exports.postUpdateProfile = function(req, res, next) {
if (err) {
return next(err);
}
req.flash('success', {msg: 'Profile information updated.'});
res.redirect('/account');
resources.updateUserStoryPictures(user._id.toString(), user.profile.picture, user.profile.username);
resources.updateUserStoryPictures(
user._id.toString(),
user.profile.picture,
user.profile.username,
function(err) {
if (err) { return next(err); }
req.flash('success', {
msg: 'Profile information updated.'
});
res.redirect('/account');
}
);
});
});
});