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
+3 -3
+3 -3
View File
@@ -740,6 +740,9 @@ router.put("/users/:id/password", async (ctx) => {
return void (ctx.status = 403);
}
const newPassword = ctx.request.body.newPassword;
if (ctx.state.user) {
const filter = and(authorizer.getFilter("users", 3), [
"=",
["PARAM", RESOURCE_IDS.users],
@@ -747,9 +750,6 @@ router.put("/users/:id/password", async (ctx) => {
]);
const { value: res } = await db.query("users", filter).next();
if (!res) return void (ctx.status = 404);
const newPassword = ctx.request.body.newPassword;
if (ctx.state.user) {
const validate = authorizer.getValidator("users", res);
if (!validate("password", { password: newPassword })) {
logUnauthorizedWarning(log);