DatabaseAuthenticator

auth. DatabaseAuthenticator

Abstracts the sign-in, sign-up and change-password processes for Database & Active Directory auhtentication services.

Constructor

new DatabaseAuthenticator(options, oauth)

Parameters:
Name Type Description
options Object Authenticator options.
Properties
Name Type Attributes Description
baseUrl String The auth0 account URL.
clientId String <optional>
Default client ID.
oauth OAuthAuthenticator OAuthAuthenticator instance.
Source:

Methods

changePassword(data, cbopt) → {Promise|undefined}

Change password using a database or active directory service.
Parameters:
Name Type Attributes Description
data Object User credentials object.
Properties
Name Type Description
email String User email address.
password String New password.
connection String Identity provider in use.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Example

Given the user email, the connection specified and the new password to use, Auth0 will send a forgot password email. Once the user clicks on the confirm password change link, the new password specified in this POST will be set to this user. Find more information in the var data = { email: '{EMAIL}', password: '{PASSWORD}', connection: 'Username-Password-Authentication' }; auth0.database.changePassword(data, function (err, message) { if (err) { // Handle error. } console.log(message); });

requestChangePasswordEmail(data, cbopt) → {Promise|undefined}

Request a change password email using a database or active directory service.
Parameters:
Name Type Attributes Description
data Object User credentials object.
Properties
Name Type Description
email String User email address.
connection String Identity provider in use.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Example

Given the user email, the connection specified, Auth0 will send a change password email. once the user clicks on the confirm password change link, the new password specified in this POST will be set to this user. Find more information in the var data = { email: '{EMAIL}', connection: 'Username-Password-Authentication' }; auth0.database.requestChangePasswordEmail(data, function (err, message) { if (err) { // Handle error. } console.log(message); });

signIn(data, cbopt) → {Promise|undefined}

Sign in using a database or active directory service.
Parameters:
Name Type Attributes Description
data Object User credentials object.
Properties
Name Type Description
username String Username.
password String User password.
connection String Identity provider in use.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Example

Given the user credentials and the connection specified, it will do the authentication on the provider and return a JSON with the `access_token` and `id_token`. Find more information about the structure of the data object in the API docs.

var data = {
  username: '{USERNAME}',
  password: '{PASSWORD}',
  connection: 'Username-Password-Authentication' // Optional field.
};

auth0.database.signIn(data, function (err, userData) {
  if (err) {
    // Handle error.
  }

  console.log(userData);
});

signUp(data, cbopt) → {Promise|undefined}

Sign up using a database or active directory service.
Parameters:
Name Type Attributes Description
data Object User credentials object.
Properties
Name Type Description
email String User email address.
password String User password.
connection Stinrg Identity provider in use.
cb function <optional>
Method callback.
Source:
Returns:
Type
Promise | undefined
Example

Given the user credentials, the connection specified and (optionally) the client ID, it will create a new user. Find more information in the API Docs.

var data = {
  email: '{EMAIL}',
  password: '{PASSWORD}',
  connection: 'Username-Password-Authentication' // Optional field.
};

auth0.database.signUp(data, function (err, userData) {
  if (err) {
    // Handle error.
  }

  console.log(userData);
});