From 3b3de541b39ea3971d90cd6efe23084ed430d868 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 9 Mar 2015 11:59:50 +0900 Subject: [PATCH] Update username for stories and comments on username change in profile --- controllers/resources.js | 4 +++- controllers/user.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/resources.js b/controllers/resources.js index 49e87a0d31..71bf06e4b6 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -298,7 +298,7 @@ module.exports = { }); })(); }, - updateUserStoryPictures: function(userId, picture) { + updateUserStoryPictures: function(userId, picture, username) { var counter = 0, foundStories, @@ -327,12 +327,14 @@ module.exports = { } R.forEach(function(comment) { comment.author.picture = picture; + comment.author.username = username; comment.markModified('author'); comment.save(); }, foundComments); R.forEach(function(story) { story.author.picture = picture; + story.author.username = username; story.markModified('author'); story.save(); }, foundStories); diff --git a/controllers/user.js b/controllers/user.js index cbdcc03d0b..d7e383a251 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -350,7 +350,7 @@ exports.postUpdateProfile = function(req, res, next) { } req.flash('success', {msg: 'Profile information updated.'}); res.redirect('/account'); - resources.updateUserStoryPictures(user._id.toString(), user.profile.picture); + resources.updateUserStoryPictures(user._id.toString(), user.profile.picture, user.profile.username); }); }); });