From 407f3d3ba73f1d29fc12125156a0305c12156d15 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Sat, 17 Nov 2018 00:58:21 +0100 Subject: [PATCH] [Fix #4] Change account password --- app/routes/user/update.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/routes/user/update.js b/app/routes/user/update.js index 4b0e19f..fa6cc24 100644 --- a/app/routes/user/update.js +++ b/app/routes/user/update.js @@ -26,7 +26,15 @@ module.exports = (req, res, next) => { return bcrypt.hash(req.body.new_password, null, null, (hashErr, hash) => { userObj.password = hash; - return userObj.save(() => res.status(200).json(userObj)); + const response = { + _id: userObj._id, + firstname: userObj.firstname, + lastname: userObj.lastname, + email: userObj.email, + createdAt: userObj.createdAt, + }; + + return userObj.save(() => res.status(200).json(response)); }); }); } else { @@ -34,7 +42,15 @@ module.exports = (req, res, next) => { userObj.lastname = req.body.lastname || userObj.lastname; userObj.email = req.body.email || userObj.email; - return userObj.save(() => res.status(200).json(userObj)); + const response = { + _id: userObj._id, + firstname: userObj.firstname, + lastname: userObj.lastname, + email: userObj.email, + createdAt: userObj.createdAt, + }; + + return userObj.save(() => res.status(200).json(response)); } }); };