Update User Profile is Not Working Inside Verify Custom Database Script - "change_email script does not exist"

Problem statement

ManagementClient.users.update does not appear to work correctly inside the verify_email custom database script. The following error is encountered:

Getting issue Error! change_email script does not exist

Solution

Function of the script

The ‘change_email’ script is required where it is desirable to update both the user’s email address (or email address verification status) in Auth0 and the external database, using a single update operation.

Consequently, the ‘change_email’ script plays a critical role in maintaining the integrity of user records in situations where a Custom Database is employed. This is because Auth0 must update both:

  • The email on the external database store.
  • The profile on the Auth0 side.

Reason for the error condition

If a Custom Database connection does not have a ‘change_email’ script configured, any attempt to update the user’s email address will result in the following error report:

“change_email script does not exist”

On the other hand, if the script exists but is incorrectly configured, this can also lead to errors. For example, the email address might be updated in the Auth0 user profile but not in the external database, giving rise to inconsistent behavior.

What might happen in those circumstances is that:

  1. The user will attempt to log in using the updated email address.
  2. Auth0 will try to search for the updated address in the external database.
  3. The user would not be found.

For this reason, the script must be correctly configured to update the email address in both the external database and the Auth0 user profile. Only then can ‘return callback(null, true);’ legitimately return a value of ‘true’.

When to use the change_email script

The Change Email Script Template script is only used in a legacy authentication scenario, where Import Mode is not enabled. For further information, refer to Configure Automatic Migration from your Database

Related References