MongoServicePassword

@accounts/mongo-passwordGlobalsMongoServicePassword

Hierarchy

  • MongoServicePassword

Implements

  • DatabaseInterfaceServicePassword

Index

Constructors

Methods

Constructors

constructor

+ new MongoServicePassword(options: MongoServicePasswordOptions): MongoServicePassword

Defined in mongo-password.ts:78

Parameters:

NameType
optionsMongoServicePasswordOptions

Returns: MongoServicePassword

Methods

addEmail

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

Defined in mongo-password.ts:245

Add an email address for a user.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
newEmailstringA new email address for the user.
verifiedbooleanWhether the new email address should be marked as verified.

Returns: Promise‹void›


addEmailVerificationToken

addEmailVerificationToken(userId: string, email: string, token: string): Promise‹void›

Defined in mongo-password.ts:361

Add an email verification token to a user.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
emailstringWhich address of the user's to link the token to.
tokenstringRandom token used to verify the user email.

Returns: Promise‹void›


addResetPasswordToken

addResetPasswordToken(userId: string, email: string, token: string, reason: string): Promise‹void›

Defined in mongo-password.ts:388

Add a reset password token to a user.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
emailstringWhich address of the user's to link the token to.
tokenstringRandom token used to verify the user email.
reasonstringReason to use for the token.

Returns: Promise‹void›


createUser

createUser(__namedParameters: object): Promise‹string›

Defined in mongo-password.ts:126

Create a new user by providing an email and/or a username and password. Emails are saved lowercased.

Parameters:

__namedParameters: object

NameType
cleanUsercleanUser
emailstring
passwordstring
usernamestring

Returns: Promise‹string›


findPasswordHash

findPasswordHash(userId: string): Promise‹string | null›

Defined in mongo-password.ts:206

Return the user password hash. If the user has no password set, will return null.

Parameters:

NameTypeDescription
userIdstringId used to query the user.

Returns: Promise‹string | null›


findUserByEmail

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

Defined in mongo-password.ts:173

Get a user by one of his emails. Email will be lowercased before running the query.

Parameters:

NameTypeDescription
emailstringEmail used to query the user.

Returns: Promise‹User | null›


findUserByEmailVerificationToken

findUserByEmailVerificationToken(token: string): Promise‹User | null›

Defined in mongo-password.ts:215

Get a user by one of the email verification token.

Parameters:

NameTypeDescription
tokenstringVerification token used to query the user.

Returns: Promise‹User | null›


findUserById

findUserById(userId: string): Promise‹User | null›

Defined in mongo-password.ts:159

Get a user by his id.

Parameters:

NameTypeDescription
userIdstringId used to query the user.

Returns: Promise‹User | null›


findUserByResetPasswordToken

findUserByResetPasswordToken(token: string): Promise‹User | null›

Defined in mongo-password.ts:229

Get a user by one of the reset password token.

Parameters:

NameTypeDescription
tokenstringReset password token used to query the user.

Returns: Promise‹User | null›


findUserByUsername

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

Defined in mongo-password.ts:188

Get a user by his username. Set the caseSensitiveUserName option to false if you want the username to be case sensitive.

Parameters:

NameType
usernamestring

Returns: Promise‹User | null›


removeAllResetPasswordTokens

removeAllResetPasswordTokens(userId: string): Promise‹void›

Defined in mongo-password.ts:414

Remove all the reset password tokens for a user.

Parameters:

NameTypeDescription
userIdstringId used to update the user.

Returns: Promise‹void›


removeEmail

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

Defined in mongo-password.ts:271

Remove an email address for a user.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
emailstringThe email address to remove.

Returns: Promise‹void›


setPassword

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

Defined in mongo-password.ts:336

Change the password for a user.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
newPasswordstringA new password for the user.

Returns: Promise‹void›


setUsername

setUsername(userId: string, newUsername: string): Promise‹void›

Defined in mongo-password.ts:315

Change the username of the user. If the username already exists, the function will fail.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
newUsernamestringA new username for the user.

Returns: Promise‹void›


setupIndexes

setupIndexes(options: Omit‹IndexOptions, "unique" | "sparse"›): Promise‹void›

Defined in mongo-password.ts:95

Setup the mongo indexes needed for the password service.

Parameters:

NameTypeDefaultDescription
optionsOmit‹IndexOptions, "unique" | "sparse"›{}Options passed to the mongo native createIndex method.

Returns: Promise‹void›


verifyEmail

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

Defined in mongo-password.ts:292

Marks the user's email address as verified.

Parameters:

NameTypeDescription
userIdstringId used to update the user.
emailstringThe email address to mark as verified.

Returns: Promise‹void›