hello, I would like to trigger an action when a user verifies their email.
I was reading other similar topics where it is recommended to set up a log-in action. But this wouldn’t be adequate since I need the action triggered only once when the user verifies.
I understand that you would like to trigger an Action after email verification.
Unfortunately, there isn’t a dedicated flow to implement an Action after a user verifies their email.
In this case, you could consider the Post-Login Action as an alternative, as you have discovered. With this approach, there is the option to check if the user’s email is verified and perform your logic.
If we consider only executing the action only once after the user verifies, we can append a custom value to the user’s user_metadata (i.e action_complete: true) and include it in our check. This way, we can guarantee execution only once.
For example:
exports.onExecutePostLogin = async (event, api) => {
if (event.user.email_verified === true && !event.user.user_metadata.action_complete){
// YOUR_LOGIC HERE
api.user.setUserMetadata("action_complete", true)
}
}