Skip to content
Merged
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
32 changes: 32 additions & 0 deletions content/docs/plugins/auth-otp/customization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ When you don't specify options, the plugin uses these sensible defaults:
customer: { accessor: 'email', entityIdAccessor: 'email' },
user: { accessor: 'email', entityIdAccessor: 'email' }
},
events: {}, // No custom priorities by default (uses EventPriority.DEFAULT)
http: {
alwaysReturnSuccess: true, // Always return success to prevent data leakage
warnOnError: true // Warn when an error occurs during OTP generation
Expand Down Expand Up @@ -187,6 +188,37 @@ The default configuration uses email for both finding actors and determining the
```


### Event Options

The `events` configuration allows you to set priority levels for OTP events. This is useful when you need certain events to be processed before others in Medusa's event system.

```ts
import { EventPriority } from "@medusajs/framework/utils"
import { Events } from "@perseidesjs/auth-otp"

{
resolve: "@perseidesjs/auth-otp",
options: {
events: {
[Events.OTP_GENERATED]: { priority: EventPriority.CRITICAL },
[Events.PRE_REGISTER_OTP_GENERATED]: { priority: EventPriority.HIGH }
}
}
}
```

Available priority levels (lower value = higher priority):

| Priority | Value | Use Case |
|----------|-------|----------|
| `CRITICAL` | 10 | Critical business events (payments, order placement) |
| `HIGH` | 50 | Important operations (customer account events) |
| `DEFAULT` | 100 | Standard priority (used when not specified) |
| `LOW` | 500 | Background operations (third-party syncs) |
| `LOWEST` | 2097152 | Internal system events |

`EventPriority` is imported from `@medusajs/framework/utils`, while `Events` is exported from `@perseidesjs/auth-otp`.

### HTTP Options

The `http` configuration provides options for handling HTTP requests:
Expand Down