Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add actor type to password reset event #9301

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions integration-tests/http/__tests__/auth/admin/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ medusaIntegrationTestRunner({
).run({
input: {
entityId: "[email protected]",
actorType: "user",
provider: "emailpass",
secret: "test",
},
Expand Down Expand Up @@ -236,6 +237,7 @@ medusaIntegrationTestRunner({
).run({
input: {
entityId: "[email protected]",
actorType: "user",
provider: "emailpass",
secret: "test",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ import {
AuthWorkflowEvents,
generateJwtToken,
MedusaError,
} from "@medusajs/utils";
} from "@medusajs/utils"
import {
createWorkflow,
transform,
WorkflowResponse,
} from "@medusajs/workflows-sdk";
import { emitEventStep, useRemoteQueryStep } from "../../common";
} from "@medusajs/workflows-sdk"
import { emitEventStep, useRemoteQueryStep } from "../../common"

export const generateResetPasswordTokenWorkflow = createWorkflow(
"generate-reset-password-token",
(input: { entityId: string; provider: string; secret: string }) => {
(input: {
entityId: string
actorType: string
provider: string
secret: string
}) => {
const providerIdentities = useRemoteQueryStep({
entry_point: "provider_identity",
fields: ["auth_identity_id", "provider_metadata"],
Expand Down Expand Up @@ -53,7 +58,7 @@ export const generateResetPasswordTokenWorkflow = createWorkflow(

emitEventStep({
eventName: AuthWorkflowEvents.PASSWORD_RESET,
data: { entity_id: input.entityId, token },
data: { entity_id: input.entityId, actorType: input.actorType, token },
})

return new WorkflowResponse(token)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const POST = async (
req: AuthenticatedMedusaRequest,
res: MedusaResponse
) => {
const { auth_provider } = req.params
const { auth_provider, actor_type } = req.params
const { identifier } = req.body

const { http } = req.scope.resolve(
Expand All @@ -19,6 +19,7 @@ export const POST = async (
await generateResetPasswordTokenWorkflow(req.scope).run({
input: {
entityId: identifier,
actorType: actor_type,
provider: auth_provider,
secret: http.jwtSecret as string,
},
Expand Down
Loading