Commit 0574f7ae by jaymehta

.

1 parent b7602474
...@@ -111,4 +111,34 @@ module.exports = createCoreController("api::end-user.end-user", () => ({ ...@@ -111,4 +111,34 @@ module.exports = createCoreController("api::end-user.end-user", () => ({
message: "OTP sent successfully", message: "OTP sent successfully",
}); });
}, },
async resetPassword(ctx) {
console.log(ctx.request.body);
const { email, password } = ctx.request.body;
const currentUser = await strapi
.query("plugin::users-permissions.user")
.findOne({
populate: ["user"],
where: {
$and: [{ email: email }],
},
});
// Check if its already existing in vendor entity
console.log("currentUser", currentUser);
await strapi.entityService.update(
"plugin::users-permissions.user",
currentUser.id,
{
data: {
password: `${password}`,
},
}
);
ctx.send({
ok: true,
message: "New password updated",
});
},
})); }));
...@@ -8,6 +8,14 @@ const routes = { ...@@ -8,6 +8,14 @@ const routes = {
// some configuration... // some configuration...
} }
}, },
{
method: "POST",
path: "/end-user/reset-password",
handler: "api::end-user.end-user.resetPassword",
config: {
// some configuration...
}
},
] ]
}; };
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!