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:
- Begin by Installing the Real-time Webtask Logs Extension on your Auth0 Dashboard > Extensions > All Extensions.
- Launch the Real-time Webtask Logs Extension by navigating to the Auth0 Dashboard > Extensions > Installed Extensions.
- 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.
-
If the user exists in Auth0, delete them using the Management API v2 Delete a user endpoint or the Delete a connection user endpoint.
-
If the user exists in your legacy database, delete them accordingly.
And then verify that they are removed from both databases.
Next, proceed with configuring the Create User Script using one of the following templates:
- JavaScript
- ASP.NET Membership Provider (MVC3 - Universal Providers)
- ASP.NET Membership Provider (MVC4 - Simple Membership)
- MongoDB
- MySQL
- PostgreSQL
- SQL Server
- Windows Azure SQL Database
- Request with Basic Auth
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.