feat(medusa,utils,core-flows): add reset password metdata (#14417)
## Summary
**What**
Adds metadata field for reset password route that allows passing data from caller that can be found in the subscriber.
## Checklist
Please ensure the following before requesting a review:
- [x] I have added a **changeset** for this PR
- Every non-breaking change should be marked as a **patch**
- To add a changeset, run `yarn changeset` and follow the prompts
- [x] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [ ] I have linked the related issue(s) if applicable
---
> [!NOTE]
> Introduces optional request `metadata` for reset-password and propagates it through to event subscribers.
>
> - Accepts `metadata` in `ResetPasswordRequest` validator and `reset-password` route; forwards it to `generateResetPasswordTokenWorkflow`
> - Workflow now accepts `metadata` and includes it in emitted `auth.password_reset` event data
> - Updates event docs to mention `metadata` field
> - Adds integration test verifying `metadata` is emitted in the password reset event
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 7f9855feabed284336e8872eebfb18fe3bd320db. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
This commit is contained in:
1 parent
d06729d0d1
commit
43305a562c
6 files changed
+58
-5
No files matched your search
@@ -11,7 +11,7 @@ export const POST = async (
|
||||
res: MedusaResponse
|
||||
) => {
|
||||
const { auth_provider, actor_type } = req.params
|
||||
const { identifier } = req.validatedBody
|
||||
const { identifier, metadata } = req.validatedBody
|
||||
|
||||
const { http } = req.scope.resolve(
|
||||
ContainerRegistrationKeys.CONFIG_MODULE
|
||||
@@ -24,6 +24,7 @@ export const POST = async (
|
||||
provider: auth_provider,
|
||||
secret: http.jwtSecret!,
|
||||
jwtOptions: http.jwtOptions,
|
||||
metadata,
|
||||
},
|
||||
throwOnError: false, // we don't want to throw on error to avoid leaking information about non-existing identities
|
||||
})
|
||||
|
||||
@@ -2,5 +2,6 @@ import { z } from "zod"
|
||||
|
||||
export const ResetPasswordRequest = z.object({
|
||||
identifier: z.string(),
|
||||
metadata: z.record(z.unknown()).optional().default({}),
|
||||
})
|
||||
export type ResetPasswordRequestType = z.infer<typeof ResetPasswordRequest>
|
||||
Reference in new issue
Block a user