Unable to delete users when using Custom Databases.
- “Sandbox Error: Please implement the Delete script for this database connection at https://manage.auth0.com/#/connections/database”
- Error - Error! There was a problem deleting firstname.lastname@example.org
- “User already exists” error message
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
- User is unable to be deleted
- Delete User script was not implemented
- User being deleted with import mode off
- User was not deleted when trying to create the user again.
There are two scenarios to consider when using Custom Databases to delete users. The first scenario is when Import Mode is enabled, and the second scenario is when Import mode is disabled.
When Import Mode is enabled, you can delete the user using the Management API v2 Delete a user endpoint to delete the user.
Or alternatively, you could use the Management API v2 Delete a connection user endpoint to delete the user.
After that is completed, confirm that the user does not exist in your legacy database.
When Import Mode is disabled, you will need to implement a Delete script in your Custom Database. Please see Delete Script Templates for a template you can use. There are templates for:
- ASP.NET Membership Provider (MVC3 - Universal Providers)
- ASP.NET Membership Provider (MVC4 - Simple Membership)
- SQL Server
- Windows Azure SQL Database
- Request with Basic Auth
Note that deleting a user using the Auth0 Dashboard or the Auth0 Management API performs deletion of both the user profile and the user identity. If you do not implement this script correctly, then this will not be done as an atomic operation, which may leave a user identity still in existence even after the user’s profile has been removed. Conversely, deleting a user identity outside of Auth0 will typically leave a disconnected (orphaned) profile in Auth0 that has no associated user identity. This may cause unpredictable issues.
If this happens, you may need to check that the user is removed from both Auth0 and your Custom Database. And then verify any issues in the Delete script to avoid this from recurring in the future.