Home Reference Source
import {User} from './core/user/user.js'
public class | source

User

Direct Subclass:

core/user/user-mock.js~UserMock

The User class is used to represent a single user on the Kinvey platform. Use the user class to manage the active user lifecycle and perform user operations.

Static Method Summary

Static Public Methods
public static

connectIdentity(identity: string, session: Object, options: Object): Promise<User>

Connect a social identity.

public static

exists(username: string, options: Object): boolean

Check if a username already exists.

public static

forgotUsername(email: string, options: Object): Promise<Object>

Request an email to be sent to recover a forgot username.

public static

getActiveUser(client: Client): User

Gets the active user.

public static

login(username: string | Object, password: string, options: Object): Promise<User>

Login using a username or password.

public static

loginWithMIC(redirectUri: string, authorizationGrant: AuthorizationGrant, options: Object): Promise<User>

Login using Mobile Identity Connect.

public static

logout(options: Object): Promise<User>

Logout the active user.

public static

lookup(query: Query, options: Object): Observable

Lookup users.

public static

me(options: Object): Promise<User>

Refresh the active user.

public static
public static

remove(id: string, options: Object): Promise

Remove a user.

public static

resetPassword(username: string, options: Object): Promise<Object>

Request an email to be sent to reset a users password.

public static

restore(): *

Restore a user that has been suspended.

public static

signup(data: User | Object, options: Object): Promise<User>

Sign up a user with Kinvey.

public static

signupWithIdentity(identity: SocialIdentity | string, session: Object, options: Object): Promise<User>

Sign up a user with Kinvey using an identity.

public static
public static

update(data: Object, options: Object): Promise<User>

Update the active user.

public static

verifyEmail(username: string, options: Object): Promise<Object>

Request an email to be sent to verify the users email.

Constructor Summary

Public Constructor
public

constructor(data: Object, options: Object): User

Create a new instance of a User.

Member Summary

Public Members
public get

The auth token for the user.

public

The users data.

public get

The email for the user.

public get

The metadata for the user.

public get

The username for the user.

Method Summary

Public Methods
public

connectIdentity(identity: string, session: Object, options: Object): Promise<User>

Connect a social identity.

public

Checks if the user is the active user.

public

Checks if the users email is verfified.

public

login(username: string | Object, password: string, options: Object): Promise<User>

Login using a username or password.

public

loginWithMIC(redirectUri: string, authorizationGrant: AuthorizationGrant, options: Object): Promise<User>

Login using Mobile Identity Connect.

public

logout(options: Object): Promise<User>

Logout the active user.

public

me(options: Object): Promise<User>

Retfresh the users data.

public
public

signup(data: User | ?Object, options: Object): Promise<User>

Sign up a user with Kinvey.

public

signupWithIdentity(identity: SocialIdentity | string, session: Object, options: Object): Promise<User>

Sign up a user with Kinvey using an identity.

public
public

update(data: Object, options: Object): Promise<User>

Update the users data.

Static Public Methods

public static connectIdentity(identity: string, session: Object, options: Object): Promise<User> source

Connect a social identity.

Params:

NameTypeAttributeDescription
identity string

Social identity.

session Object

Social identity session.

options Object
  • optional

Options

Return:

Promise<User>

The user.

public static exists(username: string, options: Object): boolean source

Check if a username already exists.

Params:

NameTypeAttributeDescription
username string

Username

options Object
  • optional

Options

Return:

boolean

True if the username already exists otherwise false.

public static forgotUsername(email: string, options: Object): Promise<Object> source

Request an email to be sent to recover a forgot username.

Params:

NameTypeAttributeDescription
email string

Email

options Object
  • optional
  • default: {}

Options

Return:

Promise<Object>

The response.

public static getActiveUser(client: Client): User source

Gets the active user. You can optionally provide a client to use to lookup the active user.

Params:

NameTypeAttributeDescription
client Client
  • optional
  • default: Client.sharedInstance()

Client to use to lookup active user.

Return:

User (nullable: true)

The active user.

public static login(username: string | Object, password: string, options: Object): Promise<User> source

Login using a username or password.

Params:

NameTypeAttributeDescription
username string | Object

Username or an object with username and password as properties.

password string
  • optional

Password

options Object
  • optional
  • default: {}

Options

Return:

Promise<User>

The user.

public static loginWithMIC(redirectUri: string, authorizationGrant: AuthorizationGrant, options: Object): Promise<User> source

Login using Mobile Identity Connect.

Params:

NameTypeAttributeDescription
redirectUri string

The redirect uri.

authorizationGrant AuthorizationGrant
  • optional
  • default: AuthoizationGrant.AuthorizationCodeLoginPage

MIC authorization grant to use.

options Object
  • optional

Options

Return:

Promise<User>

The user.

public static logout(options: Object): Promise<User> source

Logout the active user.

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Options

Return:

Promise<User>

The user.

public static lookup(query: Query, options: Object): Observable source

Lookup users.

Params:

NameTypeAttributeDescription
query Query
  • optional

Query used to filter entities.

options Object
  • optional

Options

Return:

Observable

Observable.

public static me(options: Object): Promise<User> source

Refresh the active user.

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Options

Return:

Promise<User>

The user.

public static registerForLiveService(): Promise source

Return:

Promise

public static remove(id: string, options: Object): Promise source

Remove a user.

Params:

NameTypeAttributeDescription
id string

Id of the user to remove.

options Object
  • optional

Options

options.hard boolean
  • optional
  • default: false

Boolean indicating whether user should be permanently removed from the backend (defaults to false).

Return:

Promise

public static resetPassword(username: string, options: Object): Promise<Object> source

Request an email to be sent to reset a users password.

Params:

NameTypeAttributeDescription
username string

Username

options Object
  • optional
  • default: {}

Options

Return:

Promise<Object>

The response.

public static restore(): * source

Restore a user that has been suspended.

Return:

*

public static signup(data: User | Object, options: Object): Promise<User> source

Sign up a user with Kinvey.

Params:

NameTypeAttributeDescription
data User | Object

Users data.

options Object
  • optional

Options

options.state boolean
  • optional
  • default: true

If set to true, the user will be set as the active user after successfully being signed up.

Return:

Promise<User>

The user.

public static signupWithIdentity(identity: SocialIdentity | string, session: Object, options: Object): Promise<User> source

Sign up a user with Kinvey using an identity.

Params:

NameTypeAttributeDescription
identity SocialIdentity | string

The identity.

session Object

Identity session

options Object
  • optional

Options

options.state boolean
  • optional
  • default: true

If set to true, the user will be set as the active user after successfully being signed up.

Return:

Promise<User>

The user.

public static unregisterFromLiveService(): Promise source

Return:

Promise

public static update(data: Object, options: Object): Promise<User> source

Update the active user.

Params:

NameTypeAttributeDescription
data Object

Data.

options Object
  • optional

Options

Return:

Promise<User>

The user.

public static verifyEmail(username: string, options: Object): Promise<Object> source

Request an email to be sent to verify the users email.

Params:

NameTypeAttributeDescription
username string

Username

options Object
  • optional
  • default: {}

Options

Return:

Promise<Object>

The response.

Public Constructors

public constructor(data: Object, options: Object): User source

Create a new instance of a User.

Params:

NameTypeAttributeDescription
data Object
  • optional
  • default: {}

Data for the user.

options Object
  • optional
  • default: {}

Options.

Return:

User

User

Public Members

public get authtoken: string: * source

The auth token for the user.

Return:

string (nullable: true)

Auth token

public data: Object source

The users data.

public get email: string: * source

The email for the user.

Return:

string (nullable: true)

Email

public get metadata: Metadata: * source

The metadata for the user.

Return:

Metadata

metadata

public get username: string: * source

The username for the user.

Return:

string (nullable: true)

Username

Public Methods

public connectIdentity(identity: string, session: Object, options: Object): Promise<User> source

Connect a social identity.

Params:

NameTypeAttributeDescription
identity string

Social identity.

session Object

Social identity session.

options Object
  • optional

Options

Return:

Promise<User>

The user.

public isActive(): boolean source

Checks if the user is the active user.

Return:

boolean

True the user is the active user otherwise false.

public isEmailVerified(): boolean source

Checks if the users email is verfified.

Return:

boolean

True if the users email is verified otherwise false.

public login(username: string | Object, password: string, options: Object): Promise<User> source

Login using a username or password.

Params:

NameTypeAttributeDescription
username string | Object

Username or an object with username and password as properties.

password string
  • optional

Password

options Object
  • optional
  • default: {}

Options

Return:

Promise<User>

The user.

public loginWithMIC(redirectUri: string, authorizationGrant: AuthorizationGrant, options: Object): Promise<User> source

Login using Mobile Identity Connect.

Params:

NameTypeAttributeDescription
redirectUri string

The redirect uri.

authorizationGrant AuthorizationGrant
  • optional
  • default: AuthoizationGrant.AuthorizationCodeLoginPage

MIC authorization grant to use.

options Object
  • optional

Options

Return:

Promise<User>

The user.

public logout(options: Object): Promise<User> source

Logout the active user.

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Options

Return:

Promise<User>

The user.

public me(options: Object): Promise<User> source

Retfresh the users data.

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Options

Return:

Promise<User>

The user.

public registerForLiveService(): * source

Return:

*

public signup(data: User | ?Object, options: Object): Promise<User> source

Sign up a user with Kinvey.

Params:

NameTypeAttributeDescription
data User | ?Object
  • nullable: true

Users data.

options Object
  • optional

Options

options.state boolean
  • optional
  • default: true

If set to true, the user will be set as the active user after successfully being signed up.

Return:

Promise<User>

The user.

public signupWithIdentity(identity: SocialIdentity | string, session: Object, options: Object): Promise<User> source

Sign up a user with Kinvey using an identity.

Params:

NameTypeAttributeDescription
identity SocialIdentity | string

The identity.

session Object

Identity session

options Object
  • optional

Options

options.state boolean
  • optional
  • default: true

If set to true, the user will be set as the active user after successfully being signed up.

Return:

Promise<User>

The user.

public unregisterFromLiveService(): * source

Return:

*

public update(data: Object, options: Object): Promise<User> source

Update the users data.

Params:

NameTypeAttributeDescription
data Object

Data.

options Object
  • optional

Options

Return:

Promise<User>

The user.