supertokens-node/recipe/emailpassword
References documentation for the supertokens-node/recipe/emailpassword package
Classes
default
Defined in: recipe/emailpassword/index.ts
Constructors
Constructor
new default(): default;
Returns
Properties
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
Error |
static |
typeof default |
SuperTokensError |
recipe/emailpassword/index.ts |
init |
static |
(config?) => RecipeListFunction |
Recipe.init |
recipe/emailpassword/index.ts |
Methods
consumePasswordResetToken()
static consumePasswordResetToken(
tenantId,
token,
userContext?): Promise<
| {
email: string;
status: "OK";
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
token |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
email: string;
status: "OK";
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}>
createResetPasswordLink()
static createResetPasswordLink(
tenantId,
userId,
email,
userContext?): Promise<
| {
link: string;
status: "OK";
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
userId |
string |
email |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
link: string;
status: "OK";
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>
createResetPasswordToken()
static createResetPasswordToken(
tenantId,
userId,
email,
userContext?): Promise<
| {
status: "OK";
token: string;
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
We do not make email optional here cause we want to allow passing in primaryUserId. If we make email optional, and if the user provides a primaryUserId, then it may result in two problems:
- there is no recipeUserId = input primaryUserId, in this case, this function will throw an error
- There is a recipe userId = input primaryUserId, but that recipe has no email, or has wrong email compared to what the user wanted to generate a reset token for.
And we want to allow primaryUserId being passed in.
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
userId |
string |
email |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
status: "OK";
token: string;
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>
resetPasswordUsingToken()
static resetPasswordUsingToken(
tenantId,
token,
newPassword,
userContext?): Promise<
| {
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
token |
string |
newPassword |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>
sendEmail()
static sendEmail(input): Promise<void>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
input |
TypeEmailPasswordPasswordResetEmailDeliveryInput & object |
Returns
Promise<void>
sendResetPasswordEmail()
static sendResetPasswordEmail(
tenantId,
userId,
email,
userContext?): Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
userId |
string |
email |
string |
userContext? |
Record<string, any> |
Returns
Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
}>
signIn()
Call Signature
static signIn(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session? |
undefined |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>
Call Signature
static signIn(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session |
SessionContainerInterface |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>
signUp()
Call Signature
static signUp(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session? |
undefined |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>
Call Signature
static signUp(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session |
SessionContainerInterface |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>
updateEmailOrPassword()
static updateEmailOrPassword(input): Promise<
| {
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
}
| {
reason: string;
status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
input |
{ applyPasswordPolicy?: boolean; email?: string; password?: string; recipeUserId: RecipeUserId; tenantIdForPasswordPolicy?: string; userContext?: Record<string, any>; } |
input.applyPasswordPolicy? |
boolean |
input.email? |
string |
input.password? |
string |
input.recipeUserId |
RecipeUserId |
input.tenantIdForPasswordPolicy? |
string |
input.userContext? |
Record<string, any> |
Returns
Promise<
| {
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
}
| {
reason: string;
status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>
verifyCredentials()
static verifyCredentials(
tenantId,
email,
password,
userContext?): Promise<{
status: "OK" | "WRONG_CREDENTIALS_ERROR";
}>;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
userContext? |
Record<string, any> |
Returns
Promise<{
status: "OK" | "WRONG_CREDENTIALS_ERROR";
}>
Variables
consumePasswordResetToken()
consumePasswordResetToken: (tenantId, token, userContext?) => Promise<
| {
email: string;
status: "OK";
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}> = Wrapper.consumePasswordResetToken;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
token |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
email: string;
status: "OK";
userId: string;
}
| {
status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}>
createResetPasswordLink()
createResetPasswordLink: (tenantId, userId, email, userContext?) => Promise<
| {
link: string;
status: "OK";
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.createResetPasswordLink;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
userId |
string |
email |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
link: string;
status: "OK";
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>
createResetPasswordToken()
createResetPasswordToken: (tenantId, userId, email, userContext?) => Promise<
| {
status: "OK";
token: string;
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.createResetPasswordToken;
Defined in: recipe/emailpassword/index.ts
We do not make email optional here cause we want to allow passing in primaryUserId. If we make email optional, and if the user provides a primaryUserId, then it may result in two problems:
- there is no recipeUserId = input primaryUserId, in this case, this function will throw an error
- There is a recipe userId = input primaryUserId, but that recipe has no email, or has wrong email compared to what the user wanted to generate a reset token for.
And we want to allow primaryUserId being passed in.
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
userId |
string |
email |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
status: "OK";
token: string;
}
| {
status: "UNKNOWN_USER_ID_ERROR";
}>
Error
Error: typeof default = Wrapper.Error;
Defined in: recipe/emailpassword/index.ts
init()
init: (config?) => RecipeListFunction = Wrapper.init;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
config? |
TypeInput |
Returns
resetPasswordUsingToken()
resetPasswordUsingToken: (tenantId, token, newPassword, userContext?) => Promise<
| {
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}> = Wrapper.resetPasswordUsingToken;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
token |
string |
newPassword |
string |
userContext? |
Record<string, any> |
Returns
Promise<
| {
status: "OK" | "UNKNOWN_USER_ID_ERROR" | "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>
sendEmail()
sendEmail: (input) => Promise<void> = Wrapper.sendEmail;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
input |
TypeEmailPasswordPasswordResetEmailDeliveryInput & object |
Returns
Promise<void>
sendResetPasswordEmail()
sendResetPasswordEmail: (tenantId, userId, email, userContext?) => Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
}> = Wrapper.sendResetPasswordEmail;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
userId |
string |
email |
string |
userContext? |
Record<string, any> |
Returns
Promise<{
status: "OK" | "UNKNOWN_USER_ID_ERROR";
}>
signIn()
signIn: {
(tenantId, email, password, session?, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>;
(tenantId, email, password, session, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
} = Wrapper.signIn;
Defined in: recipe/emailpassword/index.ts
Call Signature
(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>;
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session? |
undefined |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}>
Call Signature
(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session |
SessionContainerInterface |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "WRONG_CREDENTIALS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>
signUp()
signUp: {
(tenantId, email, password, session?, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>;
(tenantId, email, password, session, userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
} = Wrapper.signUp;
Defined in: recipe/emailpassword/index.ts
Call Signature
(
tenantId,
email,
password,
session?,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>;
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session? |
undefined |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}>
Call Signature
(
tenantId,
email,
password,
session,
userContext?): Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>;
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
session |
SessionContainerInterface |
userContext? |
Record<string, any> |
Returns
Promise<
| {
recipeUserId: RecipeUserId;
status: "OK";
user: User;
}
| {
status: "EMAIL_ALREADY_EXISTS_ERROR";
}
| {
reason: | "EMAIL_VERIFICATION_REQUIRED"
| "RECIPE_USER_ID_ALREADY_LINKED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR"
| "SESSION_USER_ACCOUNT_INFO_ALREADY_ASSOCIATED_WITH_ANOTHER_PRIMARY_USER_ID_ERROR";
status: "LINKING_TO_SESSION_USER_FAILED";
}>
updateEmailOrPassword()
updateEmailOrPassword: (input) => Promise<
| {
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
}
| {
reason: string;
status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}> = Wrapper.updateEmailOrPassword;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
input |
{ applyPasswordPolicy?: boolean; email?: string; password?: string; recipeUserId: RecipeUserId; tenantIdForPasswordPolicy?: string; userContext?: Record<string, any>; } |
input.applyPasswordPolicy? |
boolean |
input.email? |
string |
input.password? |
string |
input.recipeUserId |
RecipeUserId |
input.tenantIdForPasswordPolicy? |
string |
input.userContext? |
Record<string, any> |
Returns
Promise<
| {
status: "OK" | "EMAIL_ALREADY_EXISTS_ERROR" | "UNKNOWN_USER_ID_ERROR";
}
| {
reason: string;
status: "EMAIL_CHANGE_NOT_ALLOWED_ERROR";
}
| {
failureReason: string;
status: "PASSWORD_POLICY_VIOLATED_ERROR";
}>
verifyCredentials()
verifyCredentials: (tenantId, email, password, userContext?) => Promise<{
status: "OK" | "WRONG_CREDENTIALS_ERROR";
}> = Wrapper.verifyCredentials;
Defined in: recipe/emailpassword/index.ts
Parameters
| Parameter | Type |
|---|---|
tenantId |
string |
email |
string |
password |
string |
userContext? |
Record<string, any> |
Returns
Promise<{
status: "OK" | "WRONG_CREDENTIALS_ERROR";
}>
References
APIInterface
Re-exports APIInterface
APIOptions
Re-exports APIOptions
RecipeInterface
Re-exports RecipeInterface