How to change the email of a user when user confirms email in custom database

Hello Auth0 community! Wanted to ask if anyone had any advice on how to update a user’s email in Auth0 when an email update and verification event takes place in a custom database? For the most part, I followed the steps in this post.

I made sure I had a change_email script set up then have my code set up where upon new email verification in the custom database, an API call is made to api/v2/Users/patch_users_by_id with the body:

      body = {
        "email_verified": user.confirmed?,
        "email": user.email,
      }

Since the email has already been verified, I don’t actually need the change_email script in Auth0 to do anything, so I have it looking like this:

function changeEmail(oldEmail, newEmail, emailVerified, callback) {
  return callback(null, true);
}

I am however then getting an error - seems like Auth0 is then running through the get_user script and doing all kinds of verifications; however, it is searching for the old email in the custom database which no longer exists since the user has already completed the email update. Wondering if there is a way around this behavior?

1 Like

I too am trying to use the exact same solution as you Justin. I am stuck in the same spot and hoping someone could help as well.