You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A key feature of the plugin is to be able to emit an event when an OTP code is generated so that developers using the plugin can create a Subscriber, allowing them to distribute the codes to their users.
Describe the solution you'd like
There are 3 points to manage during this implementation
Initialize the EventBus module in the constructor
The first will be to add the event bus interface in the InjectedDependencies type at the main service level and initialize it in the constructor
import{IEventBusModuleService}from"@medusajs/framework/types"typeInjectedDependencies={// ... rest[Modules.EVENT_BUS]: IEventBusModuleService// ✅ This is the right interface we need to use}
Emit an event at the right place
Once everything is OK with the initialization, we need to make sure that we can emit the event, but before that, I thought it would be interesting to export a variable that could improve the DX, so that developers don't have to manage the event names manually? Something like exporting a constant that will contain all the events names (for now there is only one planned of course)
import{Events}from '@perseidesjs/auth-otp`
And could be used in a subscriber config like this :
// src/subscribers/otp-generated.tsimport{Events}from '@perseidesjs/auth-otp`
// ... subscriber logicexportconstconfig: SubscriberConfig={event: Events.OTP_GENERATED// ℹ️ This is the event submitted when the OTP is generated from the OTP provider}
Would love a feedback on this, or should we keep it simple and stupid and just put the name of the event in the docs ? 🤔
For the event emission part, we'll simply need to trigger the event following the OTP caching logic, "using the correct syntax"
Update the docs
It may seem trivial, but it's crucial to provide a brief example of usage along with the available parameters sent by the event. The identifier and the OTP are the key pieces of data in this context
Describe alternatives you've considered
No response
Priority
Critical
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
A key feature of the plugin is to be able to emit an event when an OTP code is generated so that developers using the plugin can create a Subscriber, allowing them to distribute the codes to their users.
Describe the solution you'd like
There are 3 points to manage during this implementation
Initialize the EventBus module in the constructor
The first will be to add the event bus interface in the
InjectedDependencies
type at the main service level and initialize it in the constructorEmit an event at the right place
Once everything is OK with the initialization, we need to make sure that we can emit the event, but before that, I thought it would be interesting to export a variable that could improve the DX, so that developers don't have to manage the event names manually? Something like exporting a constant that will contain all the events names (for now there is only one planned of course)
And could be used in a subscriber config like this :
Would love a feedback on this, or should we keep it simple and stupid and just put the name of the event in the docs ? 🤔
For the event emission part, we'll simply need to trigger the event following the OTP caching logic, "using the correct syntax"
Update the docs
It may seem trivial, but it's crucial to provide a brief example of usage along with the available parameters sent by the event. The
identifier
and theOTP
are the key pieces of data in this contextDescribe alternatives you've considered
No response
Priority
Critical
Additional context
No response
The text was updated successfully, but these errors were encountered: