When user verifies their email event?

Hello everyone I am new here and this is my 3rd post here, hopefully I will get an answer.

Does Auth0 have or support an onConfirm event, to explain it more in detail. When a user gets their verification email and they click the confirm link I want to add their email to a mailing list. Will that be possible?

1 Like

Hi @milos.spasovski,

There isn’t a specific onConfirm hook, but you can set something similar up with an action.

You can create an action that checks if the user is verified and has been added to your mailing list on login.

If the user has not been added and has been verified, you can add them to your mailing list and set the flag to true.

Here’s an example:

exports.onExecutePostLogin = async (event, api) => {
  if (event.user.email_verified && event.user.app_metadata.email_added) {
    console.log(`Skipping email_added because it already occurred for ${event.user.email}.`);
    return;
  }
  // add them to your mailing list
  api.user.setAppMetadata("email_added", true);
};

This is just an example of how you could do it, make sure to test that everything is working correctly before you move to production.

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