UsersManager

management. UsersManager

Abstracts interaction with the users endpoint.

Constructor

new UsersManager(options)

Parameters:
Name Type Description
options Object The client options.
Properties
Name Type Attributes Description
baseUrl String The URL of the API.
headers Object <optional>
Headers to be included in all requests.
Source:

Members

identities :external:RestClient

Provides a simple abstraction layer for linking user accounts.
Type:
Source:

multifactor :external:RestClient

Provides an abstraction layer for consuming the Multifactor Provider endpoint.
Type:
Source:

Methods

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

Create a new user.
Parameters:
Name Type Attributes Description
data Object User data.
cb function <optional>
Callback function.
Source:
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.
Parameters:
Name Type Attributes Description
params Object The user data object..
Properties
Name Type Description
id String The user id.
cb function <optional>
Callback function
Source:
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.
Parameters:
Name Type Attributes Description
cb function <optional>
Callback function
Source:
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.
Parameters:
Name Type Attributes Description
params Object Data object.
Properties
Name Type Description
id String The user id.
provider String Multifactor provider.
cb function <optional>
Callback function
Source:
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.
Parameters:
Name Type Attributes Description
data Object The user data object.
Properties
Name Type Description
id String The user id.
cb function <optional>
Callback function.
Source:
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.
Parameters:
Name Type Attributes Description
params Object <optional>
Users params.
Properties
Name Type Attributes Description
per_page Number <optional>
Number of users per page.
page Number <optional>
Page number.
cb function <optional>
Callback function.
Source:
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);
});
Link the user with another account.
Parameters:
Name Type Attributes Description
userId String ID of the primary user.
params Object Secondary user data.
Properties
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.
Source:
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.
});
Unlink the given accounts.
Parameters:
Name Type Attributes Description
params Object Linked users data.
Properties
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.
Source:
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.
Parameters:
Name Type Attributes Description
params Object The user parameters.
Properties
Name Type Description
id String The user id.
data Object New user data.
cb function <optional>
Callback function
Source:
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.
Parameters:
Name Type Attributes Description
params Object The user data object..
Properties
Name Type Description
id String The user id.
metadata Object New app metadata.
cb function <optional>
Callback function
Source:
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.
Parameters:
Name Type Attributes Description
params Object The user data object..
Properties
Name Type Description
id String The user id.
metadata Object New user metadata.
cb function <optional>
Callback function
Source:
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);
});