MongoServicePassword
Implements
- unknown
Index
Constructors
constructor
Parameters
options: MongoServicePasswordOptions
Returns MongoServicePassword
Methods
publicaddEmail
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
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
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
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
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
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
Get a user by one of the email verification token.
Parameters
token: string
Verification token used to query the user.
Returns Promise<any>
publicfindUserById
Get a user by his id.
Parameters
userId: string
Id used to query the user.
Returns Promise<any>
publicfindUserByResetPasswordToken
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
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
Remove all the reset password tokens for a user.
Parameters
userId: string
Id used to update the user.
Returns Promise<void>
publicremoveEmail
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
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
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
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
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>
Add an email address for a user.