Skip to main content
The Delete script implements the defined function to delete a specified user from an external database. We recommend naming this function deleteUser. The script is only used in a legacy authentication scenario, and is required if you want to delete a user from Auth0 and your external database in the same operation.

DeleteUser function

The deleteUser function should:
  • Remove the specified user from the external database.
  • Return a null value if the deletion succeeded.
  • Return an error if the deletion failed.

Definition

The deleteUser function accepts two parameters and returns a callback function:
ParameterTypeDescription
idStringUser’s identity user_id. Does not start with auth0.
callbackFunctionUsed to pass error or profile data through the pipeline.

Example

This is a pseudo-JavaScript example of how you could implement the deleteUser function. For language-specific examples, read Language-specific script examples.

Callback function

The callback function accepts one parameter and returns a function.

Definition

ParameterTypeRequiredDescription
errorObjectRequiredContains error data.

Return a success

If the user was successfully deleted in your external database, return the callback function, and pass a null value for the error parameter.

Example

Return an error

If an error occurs, return the callback function, and pass relevant error information to the error parameter.

Example

Language-specific script examples

Auth0 provides sample scripts for use with the following languages/technologies:

JavaScript

ASP.NET Membership Provider (MVC3 - Universal Providers)

ASP.NET Membership Provider (MVC4 - Simple Membership)

MongoDB

MySQL

PostgreSQL

SQL Server

Windows Azure SQL Database

Learn more