Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IUserManager

Interface for a user authentication state manager.

export
interface

IUserManager

Hierarchy

  • IUserManager

Implemented by

Index

Properties

isSignedIn

isSignedIn: boolean

Whether the user is signed in.

This isn't guaranteed to be 1:1 with server sign-in, the only way to be sure is to call checkIsSignedIn. But this gives a good-enough approximation for UI state display.

The differences arise when the server restarts, for instance- then the session token becomes invalid and the user must sign-in again.

onAuthStateChange

onAuthStateChange: Observable<void>

Observable that emits whenever the state of the user's sign-in has changed. UIs consuming this manager to display login state should update when this emits.

username

username: string

The username of the signed in user, or the string "Sign in..."

Methods

checkIsSignedIn

  • checkIsSignedIn(): Promise<boolean>
  • Checks user status against the server. This is intended for situations in which the client wants to verify login status, such as part of an early authentication check.

    throws

    {NetworkError} (Promise rejection) for network errors

    throws

    {TransportError} (Promise rejection) for HTTP errors

    Returns Promise<boolean>

    A promise that resolves to the sign-in state.

login

  • login(username: string, password: string): Promise<void>
  • Log-in the user, with the given username and password pair.

    Note: Logs a loud warning to the console when called over HTTP.

    throws

    {NetworkError} (Promise rejection) for network errors

    throws

    {TransportError} (Promise rejection) for HTTP errors

    throws

    {AuthenticationError} (Promise rejection) when the credentials were incorrect.

    Parameters

    • username: string
    • password: string

    Returns Promise<void>

    A promise that resolves if the action succeeded.

logout

  • logout(): Promise<void>
  • Log-out the user.

    Note: This is save to issue even if the user isn't logged in. The server will simply ignore it in that case.

    throws

    {NetworkError} (Promise rejection) for network errors

    throws

    {TransportError} (Promise rejection) for HTTP errors

    Returns Promise<void>

    A promise that resolves if the action succeeded.

Generated using TypeDoc