Skip to content

User management and authentication

The login process typically involves the following steps:

  1. The user is registered into the system by an administrative or by self-registration.
  2. The user is activated by the administrative when required, after self-registration only.
  3. The user provides their login details via system API, typically email and password.
  4. The system validates the credentials and, if valid, issues an authentication JSON Web Token (JWT), tokens are used for access and refresh.
  5. The user includes the JSON Web Token as a Bearer token in the Authorization header of subsequent API requests.
  6. The system verifies the token on each request to ensure the user is authenticated and authorized to access the requested resources.
  7. If the token is expired or invalid, the user must re-authenticate to obtain a new token.
  8. Optionally, a refresh token mechanism may be used to allow users to obtain a new JWT without re-entering credentials.
    • The refresh token is provided as the Bearer token in the Authorization header of a specific refresh endpoint.
  9. The user can log out, which typically involves invalidating the current token on the server side.
    • Invalidating the access token also invalidates the refresh token linked to the current session the access token manages.

Logs in a user with the provded email and password.

POST /api/v1/users/login
{
"email": "account.login@example.com",
"password": "#P4ssword"
}

Expected Response:

{
"status": 200,
"expiresIn": 3600,
"type": "string",
"message": "string",
"tokenType": "bearer",
"accessToken": "...",
"refreshToken": "...",
"data": [ ],
"roles": [ { <Role> } ],
"scopes": [ { <Scope> } ]
}

Description of the refresh token mechanism

Section titled “Description of the refresh token mechanism”

The refresh token mechanism is designed to allow users to obtain a new access token without re-entering their credentials. This is particularly useful for long-lived sessions where the access token may expire.

How refresh tokens are issued, validated, and renewed?

Section titled “How refresh tokens are issued, validated, and renewed?”

Issuance: When a user logs in successfully, the system issues both an access token and a refresh token. The refresh token is typically stored securely on the client side (normally on session storage).

Validation: When a client presents a refresh token to obtain a new access token, the system validates the refresh token by checking its signature and expiration date.

Renewal: If the refresh token is valid, the system issues a new access token (and possibly a new refresh token) to the client.

Endpoint for interacting with refresh tokens

Section titled “Endpoint for interacting with refresh tokens”

Refreshes the access token using the provided refresh token.

POST /api/v1/users/refresh
Authorization: Bearer <refresh_token>

Expected Response:

{
"status": 200,
"expiresIn": 3600,
"type": "string",
"message": "string",
"tokenType": "bearer",
"accessToken": "...",
"refreshToken": "...",
"data": [ ],
"roles": [ { <Role> } ],
"scopes": [ { <Scope> } ]
}

Logging out typically involves invalidating the refresh token on the server side, which also invalidates the associated access token and current session of the authenticated issuer.

  1. The user initiates the logout process, typically by clicking a “Logout” button in the UI.
  2. The client application sends a request to the server to log out the user.
  3. The server invalidates the refresh token and associated access token.
  4. The server responds to the client, confirming the logout.

Logs out the current user by invalidating the current access and refresh tokens.

POST /api/v1/users/logout
Authorization: Bearer <access_token>
Expect: 200-ok

Description of the password change process

Section titled “Description of the password change process”
  1. The client application sends a request to the server with the user’s current password and the new password.
  2. The server validates the current password and, if valid, updates the user’s password to the new password.
  3. The server responds to the client, confirming the password change.

Updates the password of the current user.

PUT /api/v1/users/change-password
Authorization: Bearer <access_token>
{
"oldPassword": "#P4ssword",
"newPassword": "#N3wP4ssword"
}

Expected Response:

{
"status": 200,
"error": false,
"errors": [ { } ],
"message": "string",
"pagination": { <Pagination> },
"data": [
{
"id": 1,
"username": "account.password",
"updatedAt": "2025-02-20T-21:05:29.648Z"
}
]
}

Description of the user registration process

Section titled “Description of the user registration process”

The phone structure typically includes fields such as phone type and phone number.

FieldTypeDescription
phoneTypeIdstringThe type of phone
phoneNumberstringThe phone number
{
"phoneTypeId": "2",
"phoneNumber": "+1 (737) 888-1234"
}

The address structure typically includes fields such as street, city, state, postal code, and country.

FieldTypeDescription
streetstringThe street address
citystringThe city address
statestringThe state or province
countrystringThe country
postalcodestringThe postal code
{
"street": "9442 N Capital of Texas Hwy",
"city": "Austin",
"state": "Texas",
"country": "United States of America",
"postalcode": "78759-0000"
}

The user structure typically includes fields which are belong to the user profile.

FieldTypeDescription
activebooleanIndicates if the user is active
departmentintegerThe department ID the user belongs to
doNotCallbooleanIndicates if the user does not want to be called
titlestringThe user’s title
salutationstringThe user’s salutation
descriptionstringA description of the user
firstNamestringThe user’s first name
lastNamestringThe user’s last name
passwordstringThe user’s password
usernamestringThe user’s username
emailstringThe user’s email
phonesarrayAn array of phone objects
addressesarrayAn array of address objects
{
"active": true,
"department": 1,
"doNotCall": true,
"title": "title",
"salutation": "salutation",
"description": "description",
"email": "account.access@example.com",
"username": "account.access",
"password": "#P4ssword",
"firstName": "Account",
"lastName": "Access",
"phones": [ { <Phone> } ],
"addresses": [ { <Address> } ]
}

Endpoint interacting with administrative user creation

Section titled “Endpoint interacting with administrative user creation”

Creates a new user with the provided details by an administrative authenticated user.

POST /api/v1/users/
Authorization: Bearer <access_token>
<User>

Endpoint interacting with user self-registration

Section titled “Endpoint interacting with user self-registration”

Creates a new user with the provided username, email and password.

POST /api/v1/users/register
Expect: 201-created
{
"email": "account.register@example.com",
"username": "account.register",
"password": "#P4ssword",
"firstName": "Account",
"lastName": "Access"
}

Get information about all users. Should get information about all active users.

NameTypeDescriptionRequiredExample
limitnumberRecords limitNo10
pagenumberRecords pageNo1
firstNamestringFirst nameNoJohn
lastNamestringLast nameNoDoe
usernamestringUsernameNousername
emailstringEmailNoaccount@example.com
activebooleanActive statusNotrue
GET /api/v1/users/
Expect: 200-ok

Expected Response:

{
"status": 200,
"error": false,
"errors": [ { } ],
"message": "string",
"data": [ { <User> } ],
"pagination": { <Pagination> }
}

Get information about a specific user.

NameTypeDescriptionRequiredExample
idstringUser IDYes123
GET /api/v1/users/:id
Expect: 200-ok

Expected Response:

{
"status": 200,
"error": false,
"errors": [ { } ],
"message": "string",
"data": { <User> },
"pagination": { <Pagination> }
}

Get information about the current user.

GET /api/v1/users/me
GET /api/v1/users/profile
Authorization: Bearer <access_token>
Expect: 200-ok

Expected Response:

{
"status": 200,
"error": false,
"errors": [ { } ],
"message": "string",
"data": { <User> },
"pagination": { <Pagination> }
}

Update information about a specific user.

NameTypeDescriptionRequiredExample
idstringUser IDYes123
PUT /api/v1/users/:id
Authorization: Bearer <access_token>
Expect: 200-ok
<User>

Expected Response:

{
"status": 200,
"error": false,
"errors": [ { } ],
"message": "string",
"data": { <User> },
"pagination": { <Pagination> }
}