Update username for stories and comments on username change in profile
This commit is contained in:
@ -298,7 +298,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
},
|
},
|
||||||
updateUserStoryPictures: function(userId, picture) {
|
updateUserStoryPictures: function(userId, picture, username) {
|
||||||
|
|
||||||
var counter = 0,
|
var counter = 0,
|
||||||
foundStories,
|
foundStories,
|
||||||
@ -327,12 +327,14 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
R.forEach(function(comment) {
|
R.forEach(function(comment) {
|
||||||
comment.author.picture = picture;
|
comment.author.picture = picture;
|
||||||
|
comment.author.username = username;
|
||||||
comment.markModified('author');
|
comment.markModified('author');
|
||||||
comment.save();
|
comment.save();
|
||||||
}, foundComments);
|
}, foundComments);
|
||||||
|
|
||||||
R.forEach(function(story) {
|
R.forEach(function(story) {
|
||||||
story.author.picture = picture;
|
story.author.picture = picture;
|
||||||
|
story.author.username = username;
|
||||||
story.markModified('author');
|
story.markModified('author');
|
||||||
story.save();
|
story.save();
|
||||||
}, foundStories);
|
}, foundStories);
|
||||||
|
@ -350,7 +350,7 @@ exports.postUpdateProfile = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
req.flash('success', {msg: 'Profile information updated.'});
|
req.flash('success', {msg: 'Profile information updated.'});
|
||||||
res.redirect('/account');
|
res.redirect('/account');
|
||||||
resources.updateUserStoryPictures(user._id.toString(), user.profile.picture);
|
resources.updateUserStoryPictures(user._id.toString(), user.profile.picture, user.profile.username);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user