Skip to main content

AccountsPasswordOptions

Index

Properties

optionalerrors

errors?: ErrorMessages

Accounts password module errors

optionalhashPassword

hashPassword?: (password: string) => Promise<string>

Function called to hash the user password, the password returned will be saved in the database directly. By default we use bcrypt to hash the password. Use this option alongside verifyPassword if you want to use argon2 for example.


Type declaration

    • (password: string): Promise<string>
    • Parameters

      • password: string

      Returns Promise<string>

optionalinvalidateAllSessionsAfterPasswordChanged

invalidateAllSessionsAfterPasswordChanged?: boolean

Invalidate existing sessions after password has been changed Default to false.

optionalinvalidateAllSessionsAfterPasswordReset

invalidateAllSessionsAfterPasswordReset?: boolean

Invalidate existing sessions after password has been reset Default to true.

optionalnotifyUserAfterPasswordChanged

notifyUserAfterPasswordChanged?: boolean

Notify a user after his password has been changed. This email is sent when the user reset his password and when he change it. Default to true.

optionalpasswordEnrollTokenExpiration

passwordEnrollTokenExpiration?: number

The number of milliseconds from when a link to set inital password is sent until token expires and user can't set password with the link anymore. Defaults to 30 days.

optionalpasswordResetTokenExpiration

passwordResetTokenExpiration?: number

The number of milliseconds from when a link to reset password is sent until token expires and user can't reset password with the link anymore. Defaults to 3 days.

optionalremoveAllResetPasswordTokensAfterPasswordChanged

removeAllResetPasswordTokensAfterPasswordChanged?: boolean

Will remove all password reset tokens from the db after a password has been changed. Default to true.

optionalrequireEmailVerification

requireEmailVerification?: boolean

Whether the email needs to be verified in order to allow authentication. From an user enumeration perspective changes what is safe to return when ambiguousErrorMessages are enabled. Can be enabled only if enableAutologin is set to false. Defaults to false.

optionalreturnTokensAfterResetPassword

returnTokensAfterResetPassword?: boolean

Default to false.

optionalsendVerificationEmailAfterSignup

sendVerificationEmailAfterSignup?: boolean

Will automatically send a verification email after signup. Default to false.

optionaltwoFactor

twoFactor?: any

Two factor options passed down to the @accounts/two-factor service.

optionalvalidateEmail

validateEmail?: (email?: string) => boolean

Function that check if the email is a valid email. This function will be called when you call createUser and addEmail.


Type declaration

    • (email?: string): boolean
    • Parameters

      • optionalemail: string

      Returns boolean

optionalvalidateNewUser

validateNewUser?: (user: CreateUserServicePassword) => any

Function that will validate the user object during createUser. The user returned from this function will be directly inserted in the database so be careful when you whitelist the fields, By default we only allow username, email and password fields.


Type declaration

    • (user: CreateUserServicePassword): any
    • Parameters

      • user: CreateUserServicePassword

      Returns any

optionalvalidatePassword

validatePassword?: (password?: string) => boolean

Function that check if the password is valid. This function will be called when you call createUser and changePassword.


Type declaration

    • (password?: string): boolean
    • Parameters

      • optionalpassword: string

      Returns boolean

optionalvalidateUsername

validateUsername?: (username?: string) => boolean

Function that check if the username is a valid username. This function will be called when you call createUser.


Type declaration

    • (username?: string): boolean
    • Parameters

      • optionalusername: string

      Returns boolean

optionalverifyEmailTokenExpiration

verifyEmailTokenExpiration?: number

The number of milliseconds from when a link to verify the user email is sent until token expires and user can't verify his email with the link anymore. Defaults to 3 days.

optionalverifyPassword

verifyPassword?: (password: string, hash: string) => Promise<boolean>

Function called to verify the password hash. By default we use bcrypt to hash the password. Use this option alongside hashPassword if you want to use argon2 for example.


Type declaration

    • (password: string, hash: string): Promise<boolean>
    • Parameters

      • password: string
      • hash: string

      Returns Promise<boolean>