@nuralogix.ai/dfx-api-client / HTTP / Users

Users

Users end points

Sample code

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

changePassword(data)

This End Point allow user to change password for already verified user.

Endpoint Action ID = 220

Parameters

NameType
dataUserChangePasswordRequest

Returns

Promise<ErrorResponse | UserChangePassword200Response>


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

NameType
dataUserCreateRequest

Returns

Promise<ErrorResponse | UserCreate200Response>


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 | UserCreateTwoFactorAuthSecret200Response>


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

NameType
userIdstring

Returns

Promise<ErrorResponse | UserDelete200Response>


disableTwoFactorAuthForLoggedInUser

disableTwoFactorAuthForLoggedInUser()

Disables 2FA for logged in user.

Endpoint Action ID = 223

Returns

Promise<ErrorResponse | UserDisableTwoFactorAuthForLoggedInUser200Response>


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

NameType
userIdstring

Returns

Promise<ErrorResponse | UserDisableTwoFactorAuthForSpecifiedUser200Response>


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

NameType
dataUserTwoFactorAuthForLoggedInUserRequest

Returns

Promise<ErrorResponse | UserEnableTwoFactorAuthForLoggedInUser200Response>


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

NameType
dataUserLoginRequest

Returns

Promise<ErrorResponse | UserLogin200Response>


loginWithPhoneCode

loginWithPhoneCode(data)

Use previously requested 6-digit code to login into a new session and obtain UserToken.

Endpoint Action ID = 217

Parameters

NameType
dataUserLoginWithPhoneCodeRequest

Returns

Promise<ErrorResponse | UserLoginWithPhoneCode200Response>


logout

logout()

Logs user out from all its sessions at once.

Endpoint Action ID = 226

Returns

Promise<ErrorResponse | UserLogout200Response>


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 | UserRemove200Response>


retrieve

retrieve()

Retrieves User account information based on the provided User Token.

Endpoint Action ID = 202

Returns

Promise<ErrorResponse | UserAccountInfo200Response>


retrieveUserRole

retrieveUserRole()

Retrieves User's Role.

Endpoint Action ID = 211

Returns

Promise<ErrorResponse | UserRetrieveRole200Response>


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

NameType
userIdstring

Returns

Promise<ErrorResponse | UserAccountVerificationCode200Response>


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

NameType
dataUserUpdateRequest

Returns

Promise<ErrorResponse | UserUpdate200Response>


verifyUserAccount

verifyUserAccount(data)

Verifies User's email address.

Endpoint Action ID = 212

Parameters

NameType
dataUserVerifyRequest

Returns

Promise<ErrorResponse | UserVerify200Response>