Responsible for storing everything related to email/password based login combinations.

interface PasswordStore {
    authenticate: ((email: string, password: string) => Promise<{
        accountId: string;
        id: string;
    }>);
    confirmVerification: ((id: string) => Promise<void>);
    create: ((email: string, accountId: string, password: string) => Promise<string>);
    delete: ((id: string) => Promise<void>);
    findByAccount: ((accountId: string) => Promise<{
        email: string;
        id: string;
    }[]>);
    findByEmail: ((email: string) => Promise<undefined | {
        accountId: string;
        id: string;
    }>);
    get: ((id: string) => Promise<undefined | {
        accountId: string;
        email: string;
    }>);
    update: ((id: string, password: string) => Promise<void>);
}

Implemented by

Properties

authenticate: ((email: string, password: string) => Promise<{
    accountId: string;
    id: string;
}>)

Authenticate if the email and password are correct and return the account and login ID if they are. Throw an error if they are not.

Type declaration

    • (email, password): Promise<{
          accountId: string;
          id: string;
      }>
    • Parameters

      • email: string

        The user's email.

      • password: string

        This user's password.

      Returns Promise<{
          accountId: string;
          id: string;
      }>

confirmVerification: ((id: string) => Promise<void>)

Confirms that the login has been verified. This can be used with, for example, email verification. The login can only be used after it is verified. In case verification is not required, this should be called immediately after the create call.

Type declaration

    • (id): Promise<void>
    • Parameters

      • id: string

        ID of the login.

      Returns Promise<void>

create: ((email: string, accountId: string, password: string) => Promise<string>)

Creates a new login entry for this account.

Type declaration

    • (email, accountId, password): Promise<string>
    • Parameters

      • email: string

        Email to log in with.

      • accountId: string

        Account ID.

      • password: string

        Password to authenticate with.

      Returns Promise<string>

delete: ((id: string) => Promise<void>)

Delete the login entry.

Type declaration

    • (id): Promise<void>
    • Parameters

      • id: string

        ID of the login object.

      Returns Promise<void>

findByAccount: ((accountId: string) => Promise<{
    email: string;
    id: string;
}[]>)

Find all login objects created by this account.

Type declaration

    • (accountId): Promise<{
          email: string;
          id: string;
      }[]>
    • Parameters

      • accountId: string

        ID of the account to find the logins for.

      Returns Promise<{
          email: string;
          id: string;
      }[]>

findByEmail: ((email: string) => Promise<undefined | {
    accountId: string;
    id: string;
}>)

Finds the account and login ID associated with this email.

Type declaration

    • (email): Promise<undefined | {
          accountId: string;
          id: string;
      }>
    • Parameters

      • email: string

        Email to find the information for.

      Returns Promise<undefined | {
          accountId: string;
          id: string;
      }>

get: ((id: string) => Promise<undefined | {
    accountId: string;
    email: string;
}>)

Finds the account and email associated with this login ID.

Type declaration

    • (id): Promise<undefined | {
          accountId: string;
          email: string;
      }>
    • Parameters

      • id: string

        The ID of the login object.

      Returns Promise<undefined | {
          accountId: string;
          email: string;
      }>

update: ((id: string, password: string) => Promise<void>)

Changes the password.

Type declaration

    • (id, password): Promise<void>
    • Parameters

      • id: string

        ID of the login object.

      • password: string

        The new password.

      Returns Promise<void>