verify
.
This script is only used in legacy authentication scenarios, and is required to support user email address verification. A verified email address is critical to a number of workflow scenarios in Auth0, and implementing this script will provide support for these out of the box.
If it’s enabled, this script is executed when a user clicks on the link in the verification email sent by Auth0.
Verify function
Theverify
function should:
- Update the
email_verified
(or equivalent) attribute in the user’s profile in the external database. - Return
true
if the update action succeeded. - Return an error if the update action failed.
Definition
Theverify
function accepts two parameters and returns a callback
function:
Parameter | Type | Description |
---|---|---|
email | String | User’s email address. |
callback | Function | Used to pass error or profile data through the pipeline. |
Example
This is a pseudo-JavaScript example of how you could implement thelogin
function. For language-specific examples, read Language-specific script examples.
Callback function
Thecallback
function is used to pass user profile data or error data through the pipeline.
Definition
Thecallback
function accepts up to two parameters and returns a function:
Parameter | Type | Required | Description |
---|---|---|---|
error | Object | Required | Contains error data. |
verified | Boolean | Optional | Contains value that represents the user’s verification status in the external database (true or false ). Only required if the value is true . |
Return a success
If the user’s verification status was updated successfully in the external database, pass anull
value for the error
parameter, and a true
value for the verified
parameter.
The Verify script does not change the value of the
email_verified
attribute in the user’s Auth0 profile, regardless of what value is returned in the callback
function.To update the email_verified
attribute in the user’s Auth0 profile, you must include the email_verified
attribute and its value in the user profile object returned in the Login and Get User scripts.Example
Return an error
If an error occurs, theerror
parameter should contain relevant information about what went wrong.
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