Options
All
  • Public
  • Public/Protected
  • All
Menu

StitchUser

The StitchUser represents the currently logged-in user of the StitchAppClient.

This can be retrieved from StitchAuth or from the result of certain methods such as StitchAuth.loginWithCredential or StitchAuth.handleRedirectResult.

See Also

Hierarchy

  • CoreStitchUser
    • StitchUser

Index

Properties

customData

customData: object

You can store arbitrary data about your application users in a MongoDB collection and configure Stitch to automatically expose each user’s data in a field of their user object. For example, you might store a user’s preferred language, date of birth, or their local timezone.

If this functionality has not been configured, it will be empty.

Type declaration

  • [key: string]: any

id

id: string

The String representation of the ID of this Stitch user.

identities

identities: StitchUserIdentity[]

An array of StitchUserIdentity objects representing the identities linked to this user which can be used to log in as this user.

isLoggedIn

isLoggedIn: boolean

Whether or not this user is logged in.

If the user is logged in, it can be switched to without reauthenticating using StitchAuth.switchToUserWithId.

Note

This is not a dynamic property. This is the state of whether or not the user was logged in at the time this user object was created. Use StitchAuth.listUsers to get a new list of users with current state.

Example

const stitchAppClient = Stitch.defaultAppClient

const {auth} = stitchAppClient

let user1 = await auth.loginWithCredential(new UserPasswordCredential('user1', 'password'))

expect('user1 is logged in', user1.isLoggedIn)

// Log out.
await auth.logout()

// The user1 object is a snapshot of the state at the time of assignment.
// Its properties will not be updated despite the internal state having changed.
expect('user1 is logged in??', user1.isLoggedIn)

// To get the current state, call StitchAuth.listUsers().
user1 = auth.listUsers().find(user => user.id === user1.id)

expect('user1 is actually logged out', user1.isLoggedIn === false)

lastAuthActivity

lastAuthActivity: Date

The time of the last auth event involving this user. This includes login, logout, and active user changed.

loggedInProviderName

loggedInProviderName: string

The name of the authentication provider used to log in as this user.

loggedInProviderType

loggedInProviderType: string

The type of authentication provider used to log in as this user.

profile

profile: StitchUserProfile

A StitchUserProfile object describing this user.

Optional userType

userType: undefined | string

A string describing the type of this user: either server or normal.

Methods

linkUserWithRedirect

  • Links this StitchUser with a new identity, where the identity is resolved via an external OAuth2 login process (e.g. Facebook or Google). This method will redirect the user to the external login page. That external page will redirect the user back to the page specified in the redirect credential. To complete the link, that page will need to handle the redirect by calling {@link StitchAuth.handleRedirectResult()}.

    Parameters

    Returns Promise<void>

linkWithCredential

  • linkWithCredential(credential: StitchCredential): Promise<StitchUser>
  • Links this StitchUser with a new identity, where the identity is defined by the credential specified as a parameter. This will only be successful if this StitchUser is the currently authenticated StitchUser for the client from which it was created.

    Parameters

    • credential: StitchCredential

      The credential to use to link this user to a new identity.

    Returns Promise<StitchUser>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc