Account update bugfix
parent
319d1b9dbd
commit
b9a7b01c1b
|
@ -13,7 +13,7 @@ module.exports = (req, res, next) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.body.password && req.body.new_password) {
|
if (req.body.password && req.body.new_password) {
|
||||||
bcrypt.compare(req.body.password, userObj.password, (error, result) => {
|
return bcrypt.compare(req.body.password, userObj.password, (error, result) => {
|
||||||
if (!result || error) {
|
if (!result || error) {
|
||||||
return next(
|
return next(
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,8 @@ module.exports = (req, res, next) => {
|
||||||
return userObj.save(() => res.status(200).json(response));
|
return userObj.save(() => res.status(200).json(response));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
|
|
||||||
userObj.firstname = req.body.firstname || userObj.firstname;
|
userObj.firstname = req.body.firstname || userObj.firstname;
|
||||||
userObj.lastname = req.body.lastname || userObj.lastname;
|
userObj.lastname = req.body.lastname || userObj.lastname;
|
||||||
userObj.email = req.body.email || userObj.email;
|
userObj.email = req.body.email || userObj.email;
|
||||||
|
@ -51,6 +52,5 @@ module.exports = (req, res, next) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return userObj.save(() => res.status(200).json(response));
|
return userObj.save(() => res.status(200).json(response));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue