Fix bug in Change Password

This commit is contained in:
Divya Jagadish authored and Zaid Humaimidi committed 2024-03-02 11:31:47 -08:00
1 parent 867e7e768d
commit 052706877a
1 file changed
+8 -8
+8 -8
View File
@@ -740,16 +740,16 @@ router.put("/users/:id/password", async (ctx) => {
return void (ctx.status = 403); return void (ctx.status = 403);
} }
const filter = and(authorizer.getFilter("users", 3), [
"=",
["PARAM", RESOURCE_IDS.users],
username,
]);
const { value: res } = await db.query("users", filter).next();
if (!res) return void (ctx.status = 404);
const newPassword = ctx.request.body.newPassword; const newPassword = ctx.request.body.newPassword;
if (ctx.state.user) { if (ctx.state.user) {
const filter = and(authorizer.getFilter("users", 3), [
"=",
["PARAM", RESOURCE_IDS.users],
username,
]);
const { value: res } = await db.query("users", filter).next();
if (!res) return void (ctx.status = 404);
const validate = authorizer.getValidator("users", res); const validate = authorizer.getValidator("users", res);
if (!validate("password", { password: newPassword })) { if (!validate("password", { password: newPassword })) {
logUnauthorizedWarning(log); logUnauthorizedWarning(log);