[Fix #6] Account update
parent
b3b1a79bee
commit
119209a73f
|
@ -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));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue