Skip to main content

MongoServicePassword

Implements

  • unknown

Index

Constructors

constructor

Methods

publicaddEmail

  • addEmail(userId: string, newEmail: string, verified: boolean): Promise<void>
  • Add an email address for a user.


    Parameters

    • userId: string

      Id used to update the user.

    • newEmail: string

      A new email address for the user.

    • verified: boolean

      Whether the new email address should be marked as verified.

    Returns Promise<void>

publicaddEmailVerificationToken

  • addEmailVerificationToken(userId: string, email: string, token: string): Promise<void>
  • Add an email verification token to a user.


    Parameters

    • userId: string

      Id used to update the user.

    • email: string

      Which address of the user's to link the token to.

    • token: string

      Random token used to verify the user email.

    Returns Promise<void>

publicaddResetPasswordToken

  • addResetPasswordToken(userId: string, email: string, token: string, reason: string): Promise<void>
  • Add a reset password token to a user.


    Parameters

    • userId: string

      Id used to update the user.

    • email: string

      Which address of the user's to link the token to.

    • token: string

      Random token used to verify the user email.

    • reason: string

      Reason to use for the token.

    Returns Promise<void>

publiccreateUser

  • createUser(__namedParameters: CreateUserServicePassword): Promise<string>
  • Create a new user by providing an email and/or a username and password. Emails are saved lowercased.


    Parameters

    • __namedParameters: CreateUserServicePassword

    Returns Promise<string>

publicfindPasswordHash

  • findPasswordHash(userId: string): Promise<null | string>
  • Return the user password hash. If the user has no password set, will return null.


    Parameters

    • userId: string

      Id used to query the user.

    Returns Promise<null | string>

publicfindUserByEmail

  • findUserByEmail(email: string): Promise<any>
  • Get a user by one of his emails. Email will be lowercased before running the query.


    Parameters

    • email: string

      Email used to query the user.

    Returns Promise<any>

publicfindUserByEmailVerificationToken

  • findUserByEmailVerificationToken(token: string): Promise<any>
  • Get a user by one of the email verification token.


    Parameters

    • token: string

      Verification token used to query the user.

    Returns Promise<any>

publicfindUserById

  • findUserById(userId: string): Promise<any>
  • Get a user by his id.


    Parameters

    • userId: string

      Id used to query the user.

    Returns Promise<any>

publicfindUserByResetPasswordToken

  • findUserByResetPasswordToken(token: string): Promise<any>
  • Get a user by one of the reset password token.


    Parameters

    • token: string

      Reset password token used to query the user.

    Returns Promise<any>

publicfindUserByUsername

  • findUserByUsername(username: string): Promise<any>
  • Get a user by his username. Set the caseSensitiveUserName option to false if you want the username to be case sensitive.


    Parameters

    • username: string

    Returns Promise<any>

publicremoveAllResetPasswordTokens

  • removeAllResetPasswordTokens(userId: string): Promise<void>
  • Remove all the reset password tokens for a user.


    Parameters

    • userId: string

      Id used to update the user.

    Returns Promise<void>

publicremoveEmail

  • removeEmail(userId: string, email: string): Promise<void>
  • Remove an email address for a user.


    Parameters

    • userId: string

      Id used to update the user.

    • email: string

      The email address to remove.

    Returns Promise<void>

publicsetPassword

  • setPassword(userId: string, newPassword: string): Promise<void>
  • Change the password for a user.


    Parameters

    • userId: string

      Id used to update the user.

    • newPassword: string

      A new password for the user.

    Returns Promise<void>

publicsetUsername

  • setUsername(userId: string, newUsername: string): Promise<void>
  • Change the username of the user. If the username already exists, the function will fail.


    Parameters

    • userId: string

      Id used to update the user.

    • newUsername: string

      A new username for the user.

    Returns Promise<void>

publicsetupIndexes

  • setupIndexes(options?: Omit<CreateIndexesOptions, unique | sparse>): Promise<void>
  • Setup the mongo indexes needed for the password service.


    Parameters

    • options: Omit<CreateIndexesOptions, unique | sparse> = {}

      Options passed to the mongo native createIndex method.

    Returns Promise<void>

publicverifyEmail

  • verifyEmail(userId: string, email: string): Promise<void>
  • Marks the user's email address as verified.


    Parameters

    • userId: string

      Id used to update the user.

    • email: string

      The email address to mark as verified.

    Returns Promise<void>