Change user e-mail address in DB connection

I create users only via the Mgmt API. I do only set fields ‘email’, ‘password’ and ‘connection’. Users receive an automatic email from Auth0 to verify their address.

Right now I want to update a user record when he wishes to change his email address. I’ll do this with a lookup first and then an update of the user by passing only the ‘email’ field with the new value.

Then, something not expected happens:

  • The user is still visbile with the old address in the “Name” field via the dashboard.
  • The user has the new address visible as “Pending”
  • The user can login with the new address
  • There is no verification mail sent to the new address
  • Subsequent queries to find the new address

My questions:

  • Why is the address set to pending?
  • Why is the email verification not sent out?
  • Why is the “Name” field not updated here as well as while user creation?

Hi @Spacefight,

Welcome to Auth0 Community! Here are the answers to your questions!

  1. Why is the address set to pending?

Address is set to pending because the user hasn’t verified their email address.

  1. Why is the email verification not sent out?

The verification email won’t be sent unless you specify verify_email:true in your PATCH request sent to /api/v2/users/{id} endpoint. (Read more in the Management API Doc’s Body Schema section: Auth0 Management API v2)

  1. Why is the “Name” field not updated here as well as while user creation?

When you create a user using the Management API by just specifying the email, password, and connection; Auth0 will automatically set the email address as the user’s Name. After that, if you want to change the Name, you have to do it manually.

Hope this helps!

1 Like

I noticied that when I trigger the verification email with the client_id of my application, the template in the email looks fine - if I do not add the client_id, the email template uses lowercase of the subdomain of my auth0 user account.

Can I trigger the correct template with the verify_email param set in the update call since I can’t pass the client_id along (I guess).

@Spacefight , can you elaborate more on what you meant by “lowercase of the subdomain”? is the verification email sent when using the /api/v2/users/{id} endpoint is different than /api/v2/jobs/verification-email endpoint?

1 Like

Yes, sure.
If I set verify_email to true when using the PHP SDK using users()->update() calls, the mail template received show the following sentence:

Welcome to myapplicationname!

Where myapplicationname is the subdomain from my auth0 account.

If I do not set the verify_email flag and call the MgmtApi a second time via jobs->sendVerificationEmail() and pass a long the client_id of the application, then the mail template received shows the following sentence:

Welcome to MyApplicationName!

Where MyApplicationName is indeed coming from the application configuration.

I would advise users to always choose a second MgmtApi call to trigger the verification email or the template looks not 100% correct to the end user.

1 Like

Thanks for sharing that with the rest of community!

1 Like

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