[Fix #6] Account update

develop
sundowndev 2018-11-17 00:53:21 +01:00
parent b3b1a79bee
commit 119209a73f
2 changed files with 3 additions and 12 deletions

View File

@ -13,7 +13,7 @@ module.exports = (req, res, next) => {
}
if (req.body.password && req.body.new_password) {
bcrypt.compare(req.body.password, user.password, (error, result) => {
bcrypt.compare(req.body.password, userObj.password, (error, result) => {
if (!result || error) {
return next(
{
@ -33,8 +33,8 @@ module.exports = (req, res, next) => {
userObj.firstname = req.body.firstname || userObj.firstname;
userObj.lastname = req.body.lastname || userObj.lastname;
userObj.email = req.body.email || userObj.email;
}
return userObj.save(() => res.status(200).json(userObj));
}
});
};

View File

@ -28,15 +28,6 @@ module.exports = (req, res, next) => {
});
}
/*if (req.body.password && req.body.password === req.body.new_password) {
return next(
{
status: 401,
message: 'New password must be different than old password.',
},
);
}*/
return next();
});
};