Class: User

User

The class representing a user entity.


new User(impl)

Parameters:
Name Type Description
impl UserImpl

An object that implements user data storage and server requests.

Members


<readonly> avatarUrl :string

User avatar image URL. Use setAvatar() to change avatar image.

Type:
  • string

<readonly> canCreateProject :Boolean

true if user is allowed to create a project.

Type:
  • Boolean

<readonly> createAt :string

User account registration time (UTC) in the format specified in ISO 8601.

Type:
  • string

<readonly> customFields :Object

User custom fields object, to store custom data.

Type:
  • Object

<readonly> data :Object

Raw user data received from the server.

Type:
  • Object

<readonly> email :string

User email.

Type:
  • string

firstName :string

First name.

Type:
  • string

<readonly> id :string

Unique user ID.

Type:
  • string

lastModified :string

User last update time (UTC) in the format specified in ISO 8601.

Type:
  • string

lastName :string

Last name.

Type:
  • string

lastSignIn :string

User last sign in time (UTC) in the format specified in ISO 8601.

Type:
  • string

<readonly> projectsLimit :Number

The maximum number of projects that a user can create.

Type:
  • Number

<readonly> token :string

The user's API key.

Type:
  • string

userName :string

User name.

Type:
  • string

Methods


<async> checkout()

Refresh user data. Only admins can checkout other users, if the current logged in user does not have administrator rights, hi can only checkout himself, otherwise an exception will be thrown.

Returns:
Type
Promise.<User>

<async> delete()

Delete a user from the server. Only admins can delete users, if the current logged in user does not have administrator rights, an exception will be thrown.

Admins can delete themselves or other admins. An admin can only delete himself if he is not the last administrator.

You need to re-login to continue working after deleting the current logged in user.

Returns:
  • Returns the raw data of a deleted user.
Type
Promise.<Object>

<async> save()

Save user data changes to the server. Call this method to update user data on the server after any changes.

Returns:
Type
Promise.<User>

<async> setAvatar(image)

Set or remove the user avatar. Only admins can set the avatar of other users, if the current logged in user does not have administrator rights, he can only set his own avatar, otherwise an exception will be thrown.

Parameters:
Name Type Description
image string | ArrayBuffer | Blob | file | null

Avatar image. Can be a Data URL string, ArrayBuffer, Blob or Web API File object. Setting the image to null will remove the avatar.

Returns:
Type
Promise.<User>

<async> update(data)

Update user data on the server. Only admins can update other users, if the current logged in user does not have administrator rights, hi can only update himself, otherwise an exception will be thrown.

Parameters:
Name Type Description
data Object

Raw user data.

Returns:
Type
Promise.<User>