feat: added PUT /api/v1/users/:uid/password route

This commit is contained in:
Julian Lam
2020-03-31 19:26:03 -04:00
parent af2e424ffe
commit 7aed174ebc
5 changed files with 73 additions and 47 deletions

View File

@@ -106,3 +106,16 @@ async function processDeletion(uid, req, res) {
email: userData.email,
});
}
Users.changePassword = async (req, res) => {
req.body.uid = req.params.uid;
await user.changePassword(req.user.uid, Object.assign(req.body, { ip: req.ip }));
await events.log({
type: 'password-change',
uid: req.user.uid,
targetUid: req.params.uid,
ip: req.ip,
});
helpers.formatApiResponse(200, res);
};