AccountsPassword

@accounts/passwordGlobalsAccountsPassword

Type parameters

CustomUser: User

Hierarchy

  • AccountsPassword

Implements

  • AuthenticationService

Index

Constructors

Properties

Methods

Constructors

constructor

+ new AccountsPassword(options: AccountsPasswordOptions): AccountsPassword

Defined in accounts-password.ts:168

Parameters:

NameTypeDefault
optionsAccountsPasswordOptions{}

Returns: AccountsPassword

Properties

server

server: AccountsServer

Defined in accounts-password.ts:165


serviceName

serviceName: string = "password"

Defined in accounts-password.ts:164


twoFactor

twoFactor: TwoFactor

Defined in accounts-password.ts:166

Methods

addEmail

addEmail(userId: string, newEmail: string, verified: boolean): Promise‹void›

Defined in accounts-password.ts:231

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 AddEmailErrors

Parameters:

NameTypeDefaultDescription
userIdstring-User id.
newEmailstring-A new email address for the user.
verifiedbooleanfalse-

Returns: Promise‹void›

  • Return a Promise.

authenticate

authenticate(params: LoginUserPasswordService): Promise‹CustomUser›

Defined in accounts-password.ts:180

Parameters:

NameType
paramsLoginUserPasswordService

Returns: Promise‹CustomUser›


changePassword

changePassword(userId: string, oldPassword: string, newPassword: string): Promise‹void›

Defined in accounts-password.ts:408

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

throws ChangePasswordErrors

Parameters:

NameTypeDescription
userIdstringUser id.
oldPasswordstringThe user's current password.
newPasswordstringA new password for the user.

Returns: Promise‹void›

  • Return a Promise.

createUser

createUser(user: CreateUserServicePassword): Promise‹string›

Defined in accounts-password.ts:593

description Create a new user.

throws CreateUserErrors

Parameters:

NameTypeDescription
userCreateUserServicePasswordThe user object.

Returns: Promise‹string›

Return the id of user created.


findUserByEmail

findUserByEmail(email: string): Promise‹CustomUser | null›

Defined in accounts-password.ts:207

description Find a user by one of his emails.

Parameters:

NameTypeDescription
emailstringUser email.

Returns: Promise‹CustomUser | null›

  • Return a user or null if not found.

findUserByUsername

findUserByUsername(username: string): Promise‹CustomUser | null›

Defined in accounts-password.ts:216

description Find a user by his username.

Parameters:

NameTypeDescription
usernamestringUser username.

Returns: Promise‹CustomUser | null›

  • Return a user or null if not found.

isTokenExpired

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

Defined in accounts-password.ts:663

Parameters:

NameType
tokenRecordTokenRecord
expiryDatenumber

Returns: boolean


removeEmail

removeEmail(userId: string, email: string): Promise‹void›

Defined in accounts-password.ts:245

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

Parameters:

NameTypeDescription
userIdstringUser id.
emailstringThe email address to remove.

Returns: Promise‹void›

  • Return a Promise.

resetPassword

resetPassword(token: string, newPassword: string, infos: ConnectionInformations): Promise‹LoginResult | null›

Defined in accounts-password.ts:295

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 ResetPasswordErrors

Parameters:

NameTypeDescription
tokenstringThe token retrieved from the reset password URL.
newPasswordstringA new password for the user.
infosConnectionInformations-

Returns: Promise‹LoginResult | null›

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

sendEnrollmentEmail

sendEnrollmentEmail(address: string): Promise‹void›

Defined in accounts-password.ts:557

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:

NameType
addressstring

Returns: Promise‹void›

  • Return a Promise.

sendResetPasswordEmail

sendResetPasswordEmail(address: string): Promise‹void›

Defined in accounts-password.ts:514

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

throws SendResetPasswordEmailErrors

Parameters:

NameType
addressstring

Returns: Promise‹void›

  • Return a Promise.

sendVerificationEmail

sendVerificationEmail(address: string): Promise‹void›

Defined in accounts-password.ts:462

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

throws SendVerificationEmailErrors

Parameters:

NameType
addressstring

Returns: Promise‹void›

  • Return a Promise.

setPassword

setPassword(userId: string, newPassword: string): Promise‹void›

Defined in accounts-password.ts:394

description Change the password for a user.

Parameters:

NameTypeDescription
userIdstringUser id.
newPasswordstringA new password for the user.

Returns: Promise‹void›

  • Return a Promise.

setStore

setStore(store: DatabaseInterface‹CustomUser›): void

Defined in accounts-password.ts:175

Parameters:

NameType
storeDatabaseInterface‹CustomUser›

Returns: void


verifyEmail

verifyEmail(token: string): Promise‹void›

Defined in accounts-password.ts:255

description Marks the user's email address as verified.

throws VerifyEmailErrors

Parameters:

NameTypeDescription
tokenstringThe token retrieved from the verification URL.

Returns: Promise‹void›

  • Return a Promise.