UsersManager

management. UsersManager

Abstracts interaction with the users endpoint.

Constructor

new UsersManager(options)

Source:
Parameters:
Name Type Description
options Object

The client options.

Name Type Attributes Description
baseUrl String

The URL of the API.

headers Object <optional>

Headers to be included in all requests.

retry Object <optional>

Retry Policy Config

Members

(inner) enrollmentsAuth0RestClient :external:RestClient

Provides an abstraction layer for retrieving Guardian enrollments.

Source:
Type:

(inner) identitiesAuth0RestClient :external:RestClient

Provides a simple abstraction layer for linking user accounts.

Source:
Type:

(inner) multifactorAuth0RestClient :external:RestClient

Provides an abstraction layer for consuming the Multifactor Provider endpoint.

Source:
Type:

(inner) userLogsAuth0RestClient :external:RestClient

Provides a simple abstraction layer for user logs

Source:
Type:

(inner) usersByEmailClient :external:RestClient

Provides an abstraction layer for the new "users-by-email" API

Source:
Type:

Methods

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

Create a new user.

Source:
Parameters:
Name Type Attributes Description
data Object

User data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.create(data, function (err) {
  if (err) {
    // Handle error.
  }

  // User created.
});

delete(params, cbopt) → {Promise|undefined}

Delete a user by its id.

Source:
Parameters:
Name Type Attributes Description
params Object

The user data object..

Name Type Description
id String

The user id.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
management.users.delete({ id: USER_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // User deleted.
});

deleteAll(cbopt) → {Promise|undefined}

Delete all users.

Source:
Parameters:
Name Type Attributes Description
cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
management.users.deleteAll(function (err) {
  if (err) {
    // Handle error.
  }

  // Users deleted
});

deleteMultifactorProvider(params, cbopt) → {Promise|undefined}

Delete a multifactor provider.

Source:
Parameters:
Name Type Attributes Description
params Object

Data object.

Name Type Description
id String

The user id.

provider String

Multifactor provider.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };

management.users.deleteMultifactorProvider(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

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

Get a user by its id.

Source:
Parameters:
Name Type Attributes Description
data Object

The user data object.

Name Type Description
id String

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.get({ id: USER_ID }, function (err, user) {
  console.log(user);
});

getAll(paramsopt, cbopt) → {Promise|undefined}

Get all users.

Source:
Parameters:
Name Type Attributes Description
params Object <optional>

Users params.

Name Type Attributes Description
per_page Number <optional>

Number of users per page.

page Number <optional>

Page number.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings and the search query.

// Pagination settings.
var params = {
  per_page: 10,
  page: 2
};

management.users.getAll(function (err, users) {
  console.log(users.length);
});

getByEmail(emailopt, cbopt) → {Promise|undefined}

Get Users by an Email Address

Source:
Parameters:
Name Type Attributes Description
email String <optional>

Email address of user(s) to find

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes a first argument as the Email address to look for users, and uses the /users-by-email API, not the search API

management.users.getByEmail('email@address', function (err, users) {
  console.log(users);
});

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

Get a list of Guardian enrollments.

Source:
Parameters:
Name Type Attributes Description
data Object

The user data object.

Name Type Description
id String

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
  console.log(enrollments);
});

Link the user with another account.

Source:
Parameters:
Name Type Attributes Description
userId String

ID of the primary user.

params Object

Secondary user data.

Name Type Description
user_id String

ID of the user to be linked.

connection_id String

ID of the connection to be used.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var data = {
	user_id: 'OTHER_USER_ID',
	connection_id: 'CONNECTION_ID'
};

management.users.link(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users linked.
});

logs(params, cbopt) → {Promise|undefined}

Get user's log events.

Source:
Parameters:
Name Type Attributes Description
params Object

Get logs data.

Name Type Description
id String

User id.

per_page Number

Number of logs per page.

page Number

Page number.

sort String

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

include_totals Boolean

true if a query summary must be included in the result, false otherwise. Default false;

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };

management.users.logs(params, function (err, logs) {
  if (err) {
    // Handle error.
  }

  console.log(logs);
});

Unlink the given accounts.

Source:
Parameters:
Name Type Attributes Description
params Object

Linked users data.

Name Type Description
id String

Primary user ID.

provider String

Identity provider in use.

user_id String

Secondary user ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };

management.users.unlink(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

update(params, data, cbopt) → {Promise|undefined}

Update a user by its id.

Source:
Parameters:
Name Type Attributes Description
params Object

The user parameters.

Name Type Description
id String

The user id.

data Object

New user data.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };

management.users.update(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the app metadata.

Source:
Parameters:
Name Type Attributes Description
params Object

The user data object..

Name Type Description
id String

The user id.

metadata Object

New app metadata.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  foo: 'bar'
};

management.users.updateAppMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the user metadata.

Source:
Parameters:
Name Type Attributes Description
params Object

The user data object..

Name Type Description
id String

The user id.

metadata Object

New user metadata.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  address: '123th Node.js Street'
};

management.users.updateUserMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});