Skip to main content

AccountsPassword <CustomUser>

Implements

  • unknown<CustomUser>

Index

Constructors

constructor

  • Type parameters

    • CustomUser: User = User

    Parameters

    Returns default<CustomUser>

Properties

options

options: AccountsPasswordOptions & { errors: ErrorMessages; hashPassword: (password: string) => Promise<string>; invalidateAllSessionsAfterPasswordChanged: boolean; invalidateAllSessionsAfterPasswordReset: boolean; notifyUserAfterPasswordChanged: boolean; passwordEnrollTokenExpiration: number; passwordResetTokenExpiration: number; removeAllResetPasswordTokensAfterPasswordChanged: boolean; requireEmailVerification: boolean; returnTokensAfterResetPassword: boolean; sendVerificationEmailAfterSignup: boolean; verifyEmailTokenExpiration: number; verifyPassword: (password: string, hash: string) => Promise<boolean>; validateEmail: any; validateNewUser: any; validatePassword: any; validateUsername: any }

publicserver

server: AccountsServer

publicserviceName

serviceName: string = 'password'

publictwoFactor

twoFactor: TwoFactor

Methods

publicaddEmail

  • addEmail(userId: string, newEmail: string, verified?: boolean): Promise<void>
  • @description

    Add an email address for a user. It will trigger the validateEmail option and throw if email is invalid. Use this instead of directly updating the database.

    @throws

    Parameters

    • userId: string

      User id.

    • newEmail: string

      A new email address for the user.

    • optionalverified: boolean = false

      Whether the new email address should be marked as verified. Defaults to false.

    Returns Promise<void>

    • Return a Promise.

publicauthenticate

  • authenticate(params: LoginUserPasswordService): Promise<CustomUser>
  • Parameters

    • params: LoginUserPasswordService

    Returns Promise<CustomUser>

publicchangePassword

  • changePassword(userId: string, oldPassword: string, newPassword: string): Promise<void>
  • @description

    Change the current user's password. It will trigger the validatePassword option and throw if password is invalid.

    @throws

    Parameters

    • userId: string

      User id.

    • oldPassword: string

      The user's current password.

    • newPassword: string

      A new password for the user.

    Returns Promise<void>

    • Return a Promise.

publiccreateUser

  • createUser(user: CreateUserServicePassword): Promise<string>
  • @description

    Create a new user.

    @throws

    Parameters

    • user: CreateUserServicePassword

      The user object.

    Returns Promise<string>

    Return the id of user created.

publicfindUserByEmail

  • findUserByEmail(email: string): Promise<null | CustomUser>
  • @description

    Find a user by one of his emails.


    Parameters

    • email: string

      User email.

    Returns Promise<null | CustomUser>

    • Return a user or null if not found.

publicfindUserByUsername

  • findUserByUsername(username: string): Promise<null | CustomUser>
  • @description

    Find a user by his username.


    Parameters

    • username: string

      User username.

    Returns Promise<null | CustomUser>

    • Return a user or null if not found.

publicisTokenExpired

  • isTokenExpired(tokenRecord: TokenRecord, expiryDate: number): boolean
  • Parameters

    • tokenRecord: TokenRecord
    • expiryDate: number

    Returns boolean

publicremoveEmail

  • removeEmail(userId: string, email: string): Promise<void>
  • @description

    Remove an email address for a user. Use this instead of directly updating the database.


    Parameters

    • userId: string

      User id.

    • email: string

      The email address to remove.

    Returns Promise<void>

    • Return a Promise.

publicresetPassword

  • resetPassword(token: string, newPassword: string, infos: ConnectionInformations): Promise<any>
  • @description

    Reset the password for a user using a token received in email. It will trigger the validatePassword option and throw if password is invalid.

    @throws

    Parameters

    • token: string

      The token retrieved from the reset password URL.

    • newPassword: string

      A new password for the user.

    • infos: ConnectionInformations

    Returns Promise<any>

    • If returnTokensAfterResetPassword option is true return the session tokens and user object, otherwise return null.

publicsendEnrollmentEmail

  • sendEnrollmentEmail(address?: string): Promise<void>
  • @description

    Send an email with a link the user can use to set their initial password. The user's email will be verified after clicking on the link.

    @throws

    SendEnrollmentEmailErrors


    Parameters

    • optionaladdress: string

      Which address of the user's to send the email to. This address must be in the user's emails list. Defaults to the first email in the list.

    Returns Promise<void>

    • Return a Promise.

publicsendResetPasswordEmail

  • sendResetPasswordEmail(address?: string): Promise<void>
  • @description

    Send an email with a link the user can use to reset their password.

    @throws

    Parameters

    • optionaladdress: string

      Which address of the user's to send the email to. This address must be in the user's emails list. Defaults to the first email in the list.

    Returns Promise<void>

    • Return a Promise.

publicsendVerificationEmail

  • sendVerificationEmail(address?: string): Promise<void>
  • @description

    Send an email with a link the user can use verify their email address.

    @throws

    Parameters

    • optionaladdress: string

      Which address of the user's to send the email to. This address must be in the user's emails list. Defaults to the first unverified email in the list. If the address is already verified we do not send any email.

    Returns Promise<void>

    • Return a Promise.

publicsetPassword

  • setPassword(userId: string, newPassword: string): Promise<void>
  • @description

    Change the password for a user.


    Parameters

    • userId: string

      User id.

    • newPassword: string

      A new password for the user.

    Returns Promise<void>

    • Return a Promise.

publicsetSessionsStore

  • setSessionsStore(store?: any): void
  • Parameters

    • optionalstore: any

    Returns void

publicsetUserStore

  • setUserStore(store: DatabaseInterfaceUser<CustomUser>): void
  • Parameters

    • store: DatabaseInterfaceUser<CustomUser>

    Returns void

publicverifyEmail

  • verifyEmail(token: string): Promise<void>
  • @description

    Marks the user's email address as verified.

    @throws

    Parameters

    • token: string

      The token retrieved from the verification URL.

    Returns Promise<void>

    • Return a Promise.