Skip to main content

User Functions

To manage users, use the functions exported by the User adapter.

Importing the adapter

To use the functions of the User adapter, import it as shown:
import { userAdapter } from 'epicenter-libs';

The userAdapter namespace exports functions that make calls to the User API.

learn more

For descriptions of the objects used by the User adapter functions, read User entities.


Create user

Create a user.

Permissions

Requires a role of FACILITATOR or higher.

Function description

The createUser() function:

Function signature
export async function createUser(
view: ExternalUserCreateView | NativeUserCreateView,
optionals: RoutingOptions = {}
): Promise<User>

Parameters

  • view (Type: ExternalUserCreateView | NativeUserCreateView): An object containing the user information required to create a new user.
  • optionals (Type: RoutingOptions = {}): Additional routing options.

Return value

A promise that resolves to a User object representing the newly created user.

Usage example

import { userAdapter } from 'epicenter-libs';

const newUser = await userAdapter.createUser({
handle: 'user@server.com',
displayName: 'Firstname Lastname',
email: 'user@server.com'
});

Get user by key

Gets a specific user by user key.

Permissions

Requires a role of PARTICIPANT or higher.

Function description

The get() function:

  • Constructs a GET request to the endpoint /user/{userKey}.
  • Retrieves information for a specific user identified by their key.
  • Returns a User object containing user details.
Function signature
export async function get(
userKey: string,
optionals: RoutingOptions = {}
): Promise<User>

Parameters

  • userKey (string): The unique key identifying the user.
  • optionals (Type: RoutingOptions = {}): Additional routing options.

Return value

A promise that resolves to a User object containing the retrieved user data.

Usage example

import { userAdapter } from 'epicenter-libs';

epicenter.userAdapter.get('00000179b4d3fb0c84f822df8cd2aa36ke96');

Get user by handle

Gets a specific user by user handle.

Permissions

Requires a role of ANONYMOUS or higher.

Function description

The getWithHandle() function:

  • Constructs a GET request to the endpoint /user/with/{handle}.
  • Optionally appends a modality to the request path.
  • Retrieves a user based on their unique handle and specified modality (if any).
  • Returns a User object containing user details.
Function signature
export async function getWithHandle(
handle: string,
optionals: {
modality?: Modality,
} & RoutingOptions = {},
): Promise<User>

Parameters

  • handle (string): The user's handle.
  • optionals (Type: { modality?: Modality } & RoutingOptions = {}):

Return value

A promise that resolves to a User object containing the user data.

Usage example

import { userAdapter } from 'epicenter-libs';

userAdapter.getWithHandle('user@server.com', { modality: 'SSO' });