Skip to main content

Class: UserUtils

Defined in: core/src/UserUtils.ts:17

Utilities for working with authenticated user objects. An user object is expected to have the following properties.

  • uid - Universally unique identifier for the user
  • email - Unique e-mail address for the user
  • roles - A list of unique names indicating the permissions of the user.
  • verified - Indicates if the user's e-mail address has been verified.

Constructors​

Constructor​

new UserUtils(): UserUtils

Returns​

UserUtils

Methods​

getExternalId()​

static getExternalId(user, type): string | undefined

Defined in: core/src/UserUtils.ts:59

Returns the unique identifier of the specified type associated with the given user.

Parameters​

user​

any

The user to retrieve the external id from.

type​

string

The type of external provider to retrieve.

Returns​

string | undefined

The unique id of the external provider for the given type if found, otherwise undefined.


hasOrganization()​

static hasOrganization(user, organizationUid): boolean

Defined in: core/src/UserUtils.ts:23

Returns true if the given user object is a member of the organization with the specified uid, otherwise returns false.

Parameters​

user​

any

The user object to inspect.

organizationUid​

string

The universally unique identifier of the persona to search for.

Returns​

boolean


hasOrganizations()​

static hasOrganizations(user, organizationUids?): boolean

Defined in: core/src/UserUtils.ts:40

Returns true if the given user object contains is a member of an organization matching one of the uids in the specified list, otherwise returns false.

Parameters​

user​

any

The user object to inspect.

organizationUids?​

string[]

The list of universally unique identifiers to search for.

Returns​

boolean


hasRole()​

static hasRole(user, role?, orgUid?): boolean

Defined in: core/src/UserUtils.ts:82

Returns true if the given user object has a role with the specified name, otherwise returns false.

Parameters​

user​

any

The user object to inspect.

role?​

string

The unique name of the role to search for.

orgUid?​

string

The unique identifier of an organization whose role will be verified.

Returns​

boolean


hasRoles()​

static hasRoles(user, roles?, orgUid?): boolean

Defined in: core/src/UserUtils.ts:107

Returns true if the given user object has at least one role from the specified list of names, otherwise returns false.

Parameters​

user​

any

The user object to inspect.

roles?​

string[]

A list of unique names of the roles to search for.

orgUid?​

string

The unique identifier of an organization whose role will be verified.

Returns​

boolean


hasScope()​

static hasScope(user, scope): boolean

Defined in: core/src/UserUtils.ts:125

Returns true if the given user object has a scope with the specified name, otherwise returns false.

Parameters​

user​

any

The user object to inspect.

scope​

string

The scope to search for.

Returns​

boolean


hasScopes()​

static hasScopes(user, scopes?): boolean

Defined in: core/src/UserUtils.ts:141

Returns true if the given user object has at least one of the specified scopes, otherwise returns false.

Parameters​

user​

any

The user object to inspect.

scopes?​

string[]

Returns​

boolean