AccountsPassword
@accounts/password › Globals › AccountsPassword
Type parameters
▪ CustomUser: User
Hierarchy
- AccountsPassword
Implements
- AuthenticationService
Index
Constructors
Properties
Methods
- addEmail
- authenticate
- changePassword
- createUser
- findUserByEmail
- findUserByUsername
- isTokenExpired
- removeEmail
- resetPassword
- sendEnrollmentEmail
- sendResetPasswordEmail
- sendVerificationEmail
- setPassword
- setStore
- verifyEmail
Constructors
constructor
+ new AccountsPassword(options
: AccountsPasswordOptions): AccountsPassword
Defined in accounts-password.ts:168
Parameters:
Name | Type | Default |
---|---|---|
options | AccountsPasswordOptions | {} |
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:
Name | Type | Default | Description |
---|---|---|---|
userId | string | - | User id. |
newEmail | string | - | A new email address for the user. |
verified | boolean | false | - |
Returns: Promise‹void›
- Return a Promise.
authenticate
▸ authenticate(params
: LoginUserPasswordService): Promise‹CustomUser›
Defined in accounts-password.ts:180
Parameters:
Name | Type |
---|---|
params | LoginUserPasswordService |
Returns: Promise‹CustomUser›
changePassword
▸ changePassword(userId
: string, oldPassword
: string, newPassword
: string): Promise‹void›
Defined in accounts-password.ts:409
description
Change the current user's password.
It will trigger the validatePassword
option and throw if password is invalid.
throws
ChangePasswordErrors
Parameters:
Name | Type | Description |
---|---|---|
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.
createUser
▸ createUser(user
: CreateUserServicePassword): Promise‹string›
Defined in accounts-password.ts:586
description
Create a new user.
throws
CreateUserErrors
Parameters:
Name | Type | Description |
---|---|---|
user | CreateUserServicePassword | The 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:
Name | Type | Description |
---|---|---|
email | string | User 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:
Name | Type | Description |
---|---|---|
username | string | User 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:657
Parameters:
Name | Type |
---|---|
tokenRecord | TokenRecord |
expiryDate | number |
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:
Name | Type | Description |
---|---|---|
userId | string | User id. |
email | string | The 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:
Name | Type | Description |
---|---|---|
token | string | The token retrieved from the reset password URL. |
newPassword | string | A new password for the user. |
infos | ConnectionInformations | - |
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:550
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:
Name | Type |
---|---|
address | string |
Returns: Promise‹void›
- Return a Promise.
sendResetPasswordEmail
▸ sendResetPasswordEmail(address
: string): Promise‹void›
Defined in accounts-password.ts:511
description
Send an email with a link the user can use to reset their password.
throws
SendResetPasswordEmailErrors
Parameters:
Name | Type |
---|---|
address | string |
Returns: Promise‹void›
- Return a Promise.
sendVerificationEmail
▸ sendVerificationEmail(address
: string): Promise‹void›
Defined in accounts-password.ts:463
description
Send an email with a link the user can use verify their email address.
throws
SendVerificationEmailErrors
Parameters:
Name | Type |
---|---|
address | string |
Returns: Promise‹void›
- Return a Promise.
setPassword
▸ setPassword(userId
: string, newPassword
: string): Promise‹void›
Defined in accounts-password.ts:395
description
Change the password for a user.
Parameters:
Name | Type | Description |
---|---|---|
userId | string | User id. |
newPassword | string | A new password for the user. |
Returns: Promise‹void›
- Return a Promise.
setStore
▸ setStore(store
: DatabaseInterface‹CustomUser›): void
Defined in accounts-password.ts:175
Parameters:
Name | Type |
---|---|
store | DatabaseInterface‹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:
Name | Type | Description |
---|---|---|
token | string | The token retrieved from the verification URL. |
Returns: Promise‹void›
- Return a Promise.