I’m trying to prevent the user email verification for users in a pre-registration trigger. The idea is that I want to pass a flag to the trigger in the meta data that would allow us to automatically verify the users email and NOT send the verification email.
You are trying to update user fields before user is even registered using pre-user-registration action. I am not sure, if this is even possible. You can likely use post-registration-action and update user call to set this field to verified.
// Use a post-registration trigger instead
// This is often more permissive with user modifications
exports.postRegistrationHandler = async (event, context) => {
if (event.user.user_metadata?.skipEmailVerification) {
// Use the link above to build your auth0 update API call.
await auth.updateUser(event.user.id, {
emailVerified: true
});
}
};
Unfortunately, as @sumansaurav mentioned, you won’t be able to disable the email verification using a pre-user registration Action. Additionally, the post-user registration Action will not work here either since it happens after the user is created.
Note that after a user is created, it will automatically send the welcome email and verification email (if enabled). Therefore, the only way to ensure that the verification email is not sent is to create the users manually using the Management API’s create a user endpoint and passing in the verify_email=false body parameter.