@nuralogix.ai/dfx-api-client
Version:
DeepAffex API JavaScript Client Library
356 lines (216 loc) • 9.58 kB
Markdown
[@nuralogix.ai/dfx-api-client](../../index.md) / [HTTP](../../http/index.md) / Users
# Users
Users end points
### Sample code
```js
const apiClient = client();
const response = await apiClient.http.users.retrieve();
const { status, body } = response;
if (status !== '200') {
/**
* TypeScript knows that once we are inside this block, the only response
* shape that matches a non "200" response is the ErrorResponse
*/
throw body;
}
/** Otherwise the shape of the response is UserAccountInfo200Response */
console.log(body.FirstName);
```
### Methods
- [changePassword](index.md#changepassword)
- [create](index.md#create)
- [createTwoFactorAuthSecret](index.md#createtwofactorauthsecret)
- [delete](index.md#delete)
- [disableTwoFactorAuthForLoggedInUser](index.md#disabletwofactorauthforloggedinuser)
- [disableTwoFactorAuthForSpecifiedUser](index.md#disabletwofactorauthforspecifieduser)
- [enableTwoFactorAuthForLoggedInUser](index.md#enabletwofactorauthforloggedinuser)
- [login](index.md#login)
- [loginWithPhoneCode](index.md#loginwithphonecode)
- [logout](index.md#logout)
- [remove](index.md#remove)
- [retrieve](index.md#retrieve)
- [retrieveUserRole](index.md#retrieveuserrole)
- [sendAccountActivationCode](index.md#sendaccountactivationcode)
- [update](index.md#update)
- [verifyUserAccount](index.md#verifyuseraccount)
### changePassword
▸ **changePassword**(`data`)
This End Point allow user to change password for already verified user.
Endpoint Action ID = 220
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserChangePasswordRequest`](interfaces/UserChangePasswordRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserChangePassword200Response`](interfaces/UserChangePassword200Response.md)\>
___
### create
▸ **create**(`data`)
Creates a new user in the organization, checking for existing user
details against the user list. Email + Password OR PhoneNumber fields
are required. If both are provided, Email + Password will be used to
create User account. The rest of the fields are optional.
Endpoint Action ID = 200
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserCreateRequest`](interfaces/UserCreateRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserCreate200Response`](interfaces/UserCreate200Response.md)\>
___
### createTwoFactorAuthSecret
▸ **createTwoFactorAuthSecret**()
Creates a base32 secret, url and a QR code (both derived from the secret)
that are compatible with Google Authenticator or similar two-factor token
generation application. The secret can be used to enable 2FA for given
user, and QR code can be used to configure compatible application to
generate login tokens for it. This is the first of two API calls needed
to configure 2FA for a user.
Endpoint Action ID = 221
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserCreateTwoFactorAuthSecret200Response`](interfaces/UserCreateTwoFactorAuthSecret200Response.md)\>
___
### delete
▸ **delete**(`userId`)
Only DFX_ORG_ADMIN has permission to delete all
measurement of specific user for its own organization.
Endpoint Action ID = 219
#### Parameters
| Name | Type |
| :------ | :------ |
| `userId` | `string` |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserDelete200Response`](interfaces/UserDelete200Response.md)\>
___
### disableTwoFactorAuthForLoggedInUser
▸ **disableTwoFactorAuthForLoggedInUser**()
Disables 2FA for logged in user.
Endpoint Action ID = 223
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserDisableTwoFactorAuthForLoggedInUser200Response`](interfaces/UserDisableTwoFactorAuthForLoggedInUser200Response.md)\>
___
### disableTwoFactorAuthForSpecifiedUser
▸ **disableTwoFactorAuthForSpecifiedUser**(`userId`)
Disables 2FA for user by its ID. This is a privileged
operation that requires ORG_ADMIN permissions.
Endpoint Action ID = 224
#### Parameters
| Name | Type |
| :------ | :------ |
| `userId` | `string` |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserDisableTwoFactorAuthForSpecifiedUser200Response`](interfaces/UserDisableTwoFactorAuthForSpecifiedUser200Response.md)\>
___
### enableTwoFactorAuthForLoggedInUser
▸ **enableTwoFactorAuthForLoggedInUser**(`data`)
Enables 2FA for logged in user using an MFASecret (created
by /users/mfa/secret endpoint) and MFAToken (derived from
MFASecret by scanning a QR code by Google Authenticator or
compatible app).
This is the second of two API calls needed to configure 2FA for
a user.The complete workflow would be as follows:
* Logged in user calls /users/mfa/enable and stores
`secretBase32Encoded` and `qrcode` properties.
* User scans `qrcode` by 2FA token generation app.
* User POSTs `secretBase32Encoded` as `MFASecret` and 2FA app
temporary token as `MFAToken` to `/users/mfa/enable` endpoint.
Endpoint Action ID = 222
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserTwoFactorAuthForLoggedInUserRequest`](interfaces/UserTwoFactorAuthForLoggedInUserRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserEnableTwoFactorAuthForLoggedInUser200Response`](interfaces/UserEnableTwoFactorAuthForLoggedInUser200Response.md)\>
___
### login
▸ **login**(`data`)
Logs a user into a new session using Email, Password and optionally an MFAToken and responds with a User Token.
The Token must be passed to every subsequent API call to the server.
Note: you need to obtain a Device Token first to be able to login through this endpoint.
Note: MFAToken token is mandatory when Multi-factor authentication is enabled for this user.
Endpoint Action ID = 201
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserLoginRequest`](interfaces/UserLoginRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserLogin200Response`](interfaces/UserLogin200Response.md)\>
___
### loginWithPhoneCode
▸ **loginWithPhoneCode**(`data`)
Use previously requested 6-digit code to login
into a new session and obtain UserToken.
Endpoint Action ID = 217
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserLoginWithPhoneCodeRequest`](interfaces/UserLoginWithPhoneCodeRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserLoginWithPhoneCode200Response`](interfaces/UserLoginWithPhoneCode200Response.md)\>
___
### logout
▸ **logout**()
Logs user out from all its sessions at once.
Endpoint Action ID = 226
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserLogout200Response`](interfaces/UserLogout200Response.md)\>
___
### remove
▸ **remove**()
Removes the entire user account, profiles, and all measurement
data associated with it. The account to be deleted is derived
from the User Token.
Endpoint Action ID = 206
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserRemove200Response`](interfaces/UserRemove200Response.md)\>
___
### retrieve
▸ **retrieve**()
Retrieves User account information based on the provided User Token.
Endpoint Action ID = 202
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserAccountInfo200Response`](interfaces/UserAccountInfo200Response.md)\>
___
### retrieveUserRole
▸ **retrieveUserRole**()
Retrieves User's Role.
Endpoint Action ID = 211
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserRetrieveRole200Response`](interfaces/UserRetrieveRole200Response.md)\>
___
### sendAccountActivationCode
▸ **sendAccountActivationCode**(`userId`)
Sends an account verification code to the user's
email address. The code is used to verify the account
through the account verification endpoint.
Endpoint Action ID = 213
#### Parameters
| Name | Type |
| :------ | :------ |
| `userId` | `string` |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserAccountVerificationCode200Response`](interfaces/UserAccountVerificationCode200Response.md)\>
___
### update
▸ **update**(`data`)
Updates a user's account information with new details. This
endpoint will only update fields supplied to it, hence sending
only First Name or Last Name will exclusively update those values.
Endpoint Action ID = 208
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserUpdateRequest`](interfaces/UserUpdateRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserUpdate200Response`](interfaces/UserUpdate200Response.md)\>
___
### verifyUserAccount
▸ **verifyUserAccount**(`data`)
Verifies User's email address.
Endpoint Action ID = 212
#### Parameters
| Name | Type |
| :------ | :------ |
| `data` | [`UserVerifyRequest`](interfaces/UserVerifyRequest.md) |
#### Returns
`Promise`<[`ErrorResponse`](../../interfaces/ErrorResponse.md) \| [`UserVerify200Response`](interfaces/UserVerify200Response.md)\>