Trouble creating users in Custom Database Connections

Problem statement

Unable to create users when using Custom Databases.

Symptoms

  • “The user already exists” error message when creating a user:
{ 
  "statusCode": 409,
  "error": "Conflict",
   "message": "The user already exists.",
    "errorCode": "auth0_idp_error"
}
  • The user is created with an existing user’s username
  • "Something went wrong. Please try again later." when signing up on the app

Troubleshooting Custom Databases Scripts

If you encounter issues with your Custom Database scripts, proceed by using the Real-time Webtask Logs Extension to troubleshoot.

Use Real-time Webtask Logs Extension:

  1. Begin by Installing the Real-time Webtask Logs Extension on your Auth0 Dashboard > Extensions > All Extensions.
  2. Launch the Real-time Webtask Logs Extension by navigating to the Auth0 Dashboard > Extensions > Installed Extensions.
  3. Using the Extension, you can view the results from your Database Scripts such as success messages, error messages, and console.log() statements.

Relevant docs:

Cause

  • Trying to create an existing user in either the Auth0 or Legacy Database.

Solution

To solve this issue, begin by checking your Auth0 and Legacy Database for the existing user in question.

Once you have found the user, remove them from the Auth0 or Legacy database.

And then verify that they are removed from both databases.

Next, proceed with configuring the Create User Script using one of the following templates:

Make sure that your Custom Database Connection has Import Mode disabled.

IMPORTANT: Note that the Get User Script is called before the Create User Script, hence you may encounter issues creating a user if the Get User script finds an existing user.

After that is complete, you should be all set and can create users when using your Custom Database.

3 Likes