Back to Medusa

Auth Module Events Reference

www/apps/resources/references/module_events/module_events.Auth/page.mdx

2.16.07.8 KB
Original Source

import { TypeList } from "docs-ui"

Auth Module Events Reference

This reference shows all the events emitted by the Medusa application related to the Auth Module. If you use the module outside the Medusa application, these events aren't emitted.

Summary

<Table> <Table.Header> <Table.Row> <Table.HeaderCell> Event </Table.HeaderCell> <Table.HeaderCell> Description </Table.HeaderCell> </Table.Row> </Table.Header> <Table.Body> <Table.Row> <Table.Cell> [auth.mfa_enabled](#authmfa_enabled) <Tooltip text="This event was added in version v2.15.5"><Badge variant="blue">v2.15.5</Badge></Tooltip> </Table.Cell> <Table.Cell> Emitted when an MFA factor is enabled for an auth identity. </Table.Cell> </Table.Row> <Table.Row> <Table.Cell> [auth.mfa_disabled](#authmfa_disabled) <Tooltip text="This event was added in version v2.15.5"><Badge variant="blue">v2.15.5</Badge></Tooltip> </Table.Cell> <Table.Cell> Emitted when an MFA factor is disabled for an auth identity. </Table.Cell> </Table.Row> <Table.Row> <Table.Cell> [auth.mfa_recovery_codes_generated](#authmfa_recovery_codes_generated) <Tooltip text="This event was added in version v2.15.5"><Badge variant="blue">v2.15.5</Badge></Tooltip> </Table.Cell> <Table.Cell> Emitted when recovery codes are generated for an auth identity. </Table.Cell> </Table.Row> <Table.Row> <Table.Cell> [auth.password_reset](#authpassword_reset) </Table.Cell> <Table.Cell> Emitted when a reset password token is generated. You can listen to this event to send a reset password email to the user or customer, for example. </Table.Cell> </Table.Row> <Table.Row> <Table.Cell> [auth.verification_requested](#authverification_requested) <Tooltip text="This event was added in version v2.15.5"><Badge variant="blue">v2.15.5</Badge></Tooltip> </Table.Cell> <Table.Cell> Emitted when a verification token is generated. You can listen to this event and decide how to deliver the token to the user or customer. </Table.Cell> </Table.Row> </Table.Body> </Table>

<EventHeader headerLvl="2" headerProps={{ id: "authmfa_enabled", children: (<>auth.mfa_enabled <Tooltip text="This event was added in version v2.15.5"> <Badge variant="blue">v2.15.5</Badge> </Tooltip></>), className: "flex flex-wrap justify-center gap-docs_0.25" }} eventName="auth.mfa_enabled" payload={\``ts { auth_identity_id, // The ID of the auth identity for which the MFA factor was enabled. mfa_id, // The ID of the MFA factor that was enabled. provider, // The provider of the MFA factor that was enabled. } ````} />

Emitted when an MFA factor is enabled for an auth identity.

Payload

ts
{
  auth_identity_id, // The ID of the auth identity for which the MFA factor was enabled.
  mfa_id, // The ID of the MFA factor that was enabled.
  provider, // The provider of the MFA factor that was enabled.
}

<EventHeader headerLvl="2" headerProps={{ id: "authmfa_disabled", children: (<>auth.mfa_disabled <Tooltip text="This event was added in version v2.15.5"> <Badge variant="blue">v2.15.5</Badge> </Tooltip></>), className: "flex flex-wrap justify-center gap-docs_0.25" }} eventName="auth.mfa_disabled" payload={\``ts { auth_identity_id, // The ID of the auth identity for which the MFA factor was disabled. mfa_id, // The ID of the MFA factor that was disabled. provider, // The provider of the MFA factor that was disabled. } ````} />

Emitted when an MFA factor is disabled for an auth identity.

Payload

ts
{
  auth_identity_id, // The ID of the auth identity for which the MFA factor was disabled.
  mfa_id, // The ID of the MFA factor that was disabled.
  provider, // The provider of the MFA factor that was disabled.
}

<EventHeader headerLvl="2" headerProps={{ id: "authmfa_recovery_codes_generated", children: (<>auth.mfa_recovery_codes_generated <Tooltip text="This event was added in version v2.15.5"> <Badge variant="blue">v2.15.5</Badge> </Tooltip></>), className: "flex flex-wrap justify-center gap-docs_0.25" }} eventName="auth.mfa_recovery_codes_generated" payload={\``ts { auth_identity_id, // The ID of the auth identity for which the recovery codes were generated. count, // (number) The number of recovery codes that were generated. } ````} />

Emitted when recovery codes are generated for an auth identity.

Payload

ts
{
  auth_identity_id, // The ID of the auth identity for which the recovery codes were generated.
  count, // (number) The number of recovery codes that were generated.
}

<EventHeader headerLvl="2" headerProps={{ id: "authpassword_reset", children: (<>auth.password_reset</>), className: "flex flex-wrap justify-center gap-docs_0.25" }} eventName="auth.password_reset" payload={\``ts { entity_id, // The identifier of the user or customer. For example, an email address. actor_type, // The type of actor. For example, "customer", "user", or custom. token, // The generated token. metadata, // Optional custom metadata passed from the request. } ````} />

Emitted when a reset password token is generated. You can listen to this event to send a reset password email to the user or customer, for example.

Payload

ts
{
  entity_id, // The identifier of the user or customer. For example, an email address.
  actor_type, // The type of actor. For example, "customer", "user", or custom.
  token, // The generated token.
  metadata, // Optional custom metadata passed from the request.
}

Workflows Emitting this Event

The following workflows emit this event when they're executed. These workflows are executed by Medusa's API routes. You can also view the events emitted by API routes in the Store and Admin API references.


<EventHeader headerLvl="2" headerProps={{ id: "authverification_requested", children: (<>auth.verification_requested <Tooltip text="This event was added in version v2.15.5"> <Badge variant="blue">v2.15.5</Badge> </Tooltip></>), className: "flex flex-wrap justify-center gap-docs_0.25" }} eventName="auth.verification_requested" payload={\``ts { entity_id, // The identifier of the user or customer. For example, an email address. actor_type, // The type of actor. For example, "customer", "user", or custom. provider, // The auth provider that requested verification. auth_identity_id, // The ID of the auth identity being verified. provider_identity_id, // The ID of the provider identity being verified. token, // The generated token. expires_at, // The token expiry date. metadata, // Optional custom metadata passed from the request. } ````} />

Emitted when a verification token is generated. You can listen to this event and decide how to deliver the token to the user or customer.

Payload

ts
{
  entity_id, // The identifier of the user or customer. For example, an email address.
  actor_type, // The type of actor. For example, "customer", "user", or custom.
  provider, // The auth provider that requested verification.
  auth_identity_id, // The ID of the auth identity being verified.
  provider_identity_id, // The ID of the provider identity being verified.
  token, // The generated token.
  expires_at, // The token expiry date.
  metadata, // Optional custom metadata passed from the request.
}

Workflows Emitting this Event

The following workflows emit this event when they're executed. These workflows are executed by Medusa's API routes. You can also view the events emitted by API routes in the Store and Admin API references.