Options
All
  • Public
  • Public/Protected
  • All
Menu

Log in to a remote authentication service, using an OnlineWithAuthentication or an Online identity.

Hierarchy

  • Authenticator

Index

Properties

loginSupported: boolean

Returns true if authentication is avaiable and the login methods can be used, otherwise returns false. Currently, authentication is only available if Ditto was initialized with an identity of type 'onlineWithAuthentication'.

Returns the current authentication status.

Accessors

  • get isAuthenticated(): boolean
  • Query whether Ditto has a valid authentication token.

    This will only be true when using an OnlineWithAuthentication or an Online identity, after a successful login. If the authentication token is allowed to expire then it will return false instead.

    deprecated:

    use status.isAuthenticated property instead.

    Returns boolean

  • get userID(): string
  • Return the currently logged-in user ID.

    This will be null if there is no valid authentication or OnlineWithAuthentication/Online mode is not being used.

    deprecated:

    use status.userID property instead.

    Returns string

Methods

  • loginWithToken(token: string, provider: string): Promise<void>
  • Log in to Ditto with a third-party token. Throws if authentication is not available, which can be checked with loginSupported.

    Parameters

    • token: string

      the authentication token required to log in.

    • provider: string

      the name of the authentication provider.

    Returns Promise<void>

  • loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void>
  • Log in to Ditto with a username and password. Throws if authentication is not available, which can be checked with loginSupported.

    Parameters

    • username: string

      the username component of the credentials used for log in.

    • password: string

      the password component of the credentials used for log in.

    • provider: string

      the name of the authentication provider.

    Returns Promise<void>

  • logout(cleanupFn?: (Ditto: any) => void): Promise<void>
  • Log out of Ditto.

    This will stop sync, shut down all replication sessions, and remove any cached authentication credentials. Note that this does not remove any data from the store. If you wish to delete data from the store then use the optional cleanupFn parameter to perform any required cleanup.

    Parameters

    • Optional cleanupFn: (Ditto: any) => void

      An optional function that will be called with the relevant [Ditto] instance as the sole argument that allows you to perform any required cleanup of the store as part of the logout process.

        • (Ditto: any): void
        • Parameters

          • Ditto: any

          Returns void

    Returns Promise<void>