Change Email Script Template

Change Email Script Template

The Change Email script implements the function executed when a change in the email address, or the email address verification status, for a user occurs. We recommend naming this function changeEmail. Typically, the script is executed when a change in either email address and/or email address verification status is actioned via the Auth0 Dashboard or the Auth0 Management API. The script is only used in a legacy authentication scenario, and must be implemented if support is required for email address/status change via Auth0.

The change email script is not configurable via the Auth0 Dashboard. There are no script templates available. You can use either the Auth0 Deploy CLI Tool or the Auth0 Management API to create or update the change email script.

The changeEmail function should be defined as follows:

function changeEmail(email, newEmail, verified, callback) {
  // TODO: implement your script
  return callback(null);
}

Was this helpful?

/

Parameter Description
email The email address for the user as the user identifying credential.
newEmail The new email address for the user.
verified The verified state of the new email address, passed as either a true or false value. Email verification status information is typically returned via email_verified as part of any user profile information returned (see login and get user for further details), so email verification state should be preserved in the legacy data store for future reference.
callback Executed with up to two parameters. The first parameter is an indication of status: a null first parameter with a corresponding second parameter of true indicates that the operation executed successfully; a null first parameter with no corresponding second parameter (or one with a value of false) indicates that no email change was performed (possibly due to the user not being found). A non null first parameter value indicates that some error condition occurred.

Best practice

When indicating an error, we recommend using the Error object to provide Auth0 with a clear indication of the error condition. For example, use callback(new Error(“an error message”)) when a problems occurs with communication to your database. To learn more, read the "Type of Errors" section in Troubleshoot Custom Databases.

Learn more

On This Page