Users
Managing users
The Users module is used to manage users. It provides a number of methods for creating, updating, and deleting users.
createUser
The nile.api.users.createUser
method is used to create a new user.
Parameters
email
: The email of the user to create.password
: The password of the user to create.preferredName
: Optional. The preferred name of the user to create.newTenant
: Optional. Name of a new tenant to create for the user.
Returns
When successful, a promise that resolves to a User
object.
When the user already exists, a promise that resolves to a Response object with 404 status code and text body Not Found
.
Examples
Here are some examples of how to use the nile.api.users.createUser
method and the expected responses:
createTenantUser
The nile.api.users.createTenantUser
method is used to create a new user in the current tenant.
Parameters
email
: The email of the user to create.password
: The password of the user to create.preferredName
: Optional. The preferred name of the user to create.newTenant
: Optional and unused.
Returns
When successful, a promise that resolves to a User
object.
If unauthenticated, a promise that resolves to a Response object with 401 status code.
Examples
me
The nile.api.users.me
method is used to get information about the current user.
Returns
If succeeds, a promise that resolves to a User
object.
If unauthenticated, a promise that resolves to a Response object with 401 status code.
Examples
updateMe
The nile.api.users.updateMe
method is used to update the current user.
Parameters
User
object with one or more of the following properties:
- name
- familyName
- givenName
- picture (string with url to the picture)
- emailVerified
Email address, ID, created and updated properties cannot be modified. Tenant membership is updated via the nile.api.users.linkTenant
and nile.api.users.unlinkTenant
methods.
Password reset currently cannot be done via the SDK, refer to the Password Reset documentation for more information.
Returns
If successful, a promise that resolves to a User
object with the new values.
If unauthenticated, a promise that resolves to a Response object with 401 status code.
Examples
linkUser
The nile.api.users.linkUser
method is used to give an existing user access to a tenant.
Parameters
id
: The ID of the user to link.tenantId
: Optional. The ID of the tenant to link the user to. If not provided, the user will be linked to the current tenant.
Returns
- User object if successful. This method succeeds even if the user is already a member of the tenant.
- 401 Unauthorized if unauthenticated
- 404 Not Found if the user does not exist, the tenant does not exist, or the current user does not have permission to access the specified tenant.
Examples
unlinkUser
The nile.api.users.unlinkUser
method is used to remove user’s access to a tenant, without deleting the user.
Parameters
userId
: The ID of the user to unlink.tenantId
: Optional. The ID of the tenant to unlink the user from. If not provided, the user will be unlinked from the current tenant.
Returns
- 204 No Content if successful
- 401 Unauthorized if unauthenticated
- 404 Not Found if the user is not a member of the current tenant, the user does not exist, the tenant does not exist, or the current user does not have permission to access the current tenant.
Examples
listUsers
The nile.api.users.listUsers
method is used to list all users in the current tenant.
Returns
- Array with
User
objects if successful. - 401 Unauthorized if unauthenticated.
- 400 If current tenant is not set (
nile.tenantId
isnull
orundefined
). - 404 Not Found if the current user does not have permission to access the current tenant.
Examples
updateUser
The nile.api.users.updateUser
method is used to update a user. A user can only update other users in the same tenant.
Parameters
User
object with one or more of the following properties:
- id
- name
- familyName
- givenName
- picture (string with url to the picture)
- emailVerified
If id
is not provided, the method will use the id from nile.userId
.
Email address, ID, created and updated properties cannot be modified. Tenant membership is updated via the nile.api.users.linkTenant
and nile.api.users.unlinkTenant
methods.
Password reset currently cannot be done via the SDK, refer to the Password Reset documentation for more information.
Returns
If successful, a promise that resolves to a User
object with the new values.
If unauthenticated, a promise that resolves to a Response object with 401 status code. If the current user does not share a tenant with the user being updated, a promise that resolves to a Response object with 404 status code.