Trigger action on user email verification

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.

How would I go about this if it is possible?

Hi @jpb,

Welcome to the Auth0 Community!

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) 
  }
}

Please take a moment to review Event Object and API Object for the Post-Login Action.

Hoped this helps!

Please let me know if you need additional clarification or have further questions.

Thank you.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.