Skip to content
Esc
navigateopen⌘Jpreview
Dashboard
On this page

supertokens-web-js/recipe/emailpassword

References documentation for the supertokens-web-js/recipe/emailpassword package

Classes

default

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Constructors

Constructor
new default(): default;
Returns

default

Methods

doesEmailExist()
static doesEmailExist(input): Promise<{
  doesExist: boolean;
  fetchResponse: Response;
  status: "OK";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Check if an email exists

Parameters
Parameter Type
input { email: string; options?: RecipeFunctionOptions; userContext?: any; }
input.email string
input.options? RecipeFunctionOptions
input.userContext? any
Returns

Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK"; }>

{status: "OK", doesExist: boolean}

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

getResetPasswordTokenFromURL()
static getResetPasswordTokenFromURL(input?): string;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Reads and returns the reset password token from the current URL

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

string

The “token” query parameter from the current location

getTenantIdFromURL()
static getTenantIdFromURL(input?): string;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Reads and returns the tenant id from the current URL

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

string

The “tenantId” query parameter from the current location

init()
static init(config?): CreateRecipeFunction<PreAndPostAPIHookAction>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Parameters
Parameter Type
config? UserInput
Returns

CreateRecipeFunction<PreAndPostAPIHookAction>

sendPasswordResetEmail()
static sendPasswordResetEmail(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "PASSWORD_RESET_NOT_ALLOWED";
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Send an email to the user for password reset

Parameters
Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.userContext? any
Returns

Promise< | { fetchResponse: Response; status: "OK"; } | { fetchResponse: Response; reason: string; status: "PASSWORD_RESET_NOT_ALLOWED"; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

signIn()
static signIn(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  user: User;
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}
  | {
  fetchResponse: Response;
  status: "WRONG_CREDENTIALS_ERROR";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_IN_NOT_ALLOWED";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Sign in a user with email and password

Parameters
Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.shouldTryLinkingWithSessionUser? boolean
input.userContext? any
Returns

Promise< | { fetchResponse: Response; status: "OK"; user: User; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; } | { fetchResponse: Response; status: "WRONG_CREDENTIALS_ERROR"; } | { fetchResponse: Response; reason: string; status: "SIGN_IN_NOT_ALLOWED"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

signOut()
static signOut(input?): Promise<void>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Parameters
Parameter Type
input? { userContext?: any; }
input.userContext? any
Returns

Promise<void>

signUp()
static signUp(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  user: User;
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_UP_NOT_ALLOWED";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Sign up a user with email and password

Parameters
Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.shouldTryLinkingWithSessionUser? boolean
input.userContext? any
Returns

Promise< | { fetchResponse: Response; status: "OK"; user: User; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; } | { fetchResponse: Response; reason: string; status: "SIGN_UP_NOT_ALLOWED"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

submitNewPassword()
static submitNewPassword(input): Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  fetchResponse: Response;
  status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}>;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Submit a new password for the user

Parameters
Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.userContext? any
Returns

Promise< | { fetchResponse: Response; status: "OK"; } | { fetchResponse: Response; status: "RESET_PASSWORD_INVALID_TOKEN_ERROR"; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

Type Aliases

RecipeFunctionOptions

type RecipeFunctionOptions = object;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/recipeModule/types.ts

For the options object passed to recipe functions, we do not need a postAPIHook.

This is because these functions will be called manually, so the user always knows which API is called (making the postAPIHook redundant). They can consume the networkResponse returned by recipe functions as a way to handle post API logic

Properties

Property Type Defined in
preAPIHook? (input) => Promise<{ requestInit: RequestInit; url: string; }> tmp/supertokens-web-js/lib/ts/recipe/recipeModule/types.ts

Variables

doesEmailExist()

const doesEmailExist: (input) => Promise<{
  doesExist: boolean;
  fetchResponse: Response;
  status: "OK";
}> = RecipeWrapper.doesEmailExist;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Check if an email exists

Parameters

Parameter Type
input { email: string; options?: RecipeFunctionOptions; userContext?: any; }
input.email string
input.options? RecipeFunctionOptions
input.userContext? any

Returns

Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK"; }>

{status: "OK", doesExist: boolean}

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


getResetPasswordTokenFromURL()

const getResetPasswordTokenFromURL: (input?) => string = RecipeWrapper.getResetPasswordTokenFromURL;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Reads and returns the reset password token from the current URL

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

string

The “token” query parameter from the current location


getTenantIdFromURL()

const getTenantIdFromURL: (input?) => string = RecipeWrapper.getTenantIdFromURL;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Reads and returns the tenant id from the current URL

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

string

The “tenantId” query parameter from the current location


init()

const init: (config?) => CreateRecipeFunction<PreAndPostAPIHookAction> = RecipeWrapper.init;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Parameters

Parameter Type
config? UserInput

Returns

CreateRecipeFunction<PreAndPostAPIHookAction>


sendPasswordResetEmail()

const sendPasswordResetEmail: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "PASSWORD_RESET_NOT_ALLOWED";
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}> = RecipeWrapper.sendPasswordResetEmail;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Send an email to the user for password reset

Parameters

Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.userContext? any

Returns

Promise< | { fetchResponse: Response; status: "OK"; } | { fetchResponse: Response; reason: string; status: "PASSWORD_RESET_NOT_ALLOWED"; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


signIn()

const signIn: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  user: User;
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}
  | {
  fetchResponse: Response;
  status: "WRONG_CREDENTIALS_ERROR";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_IN_NOT_ALLOWED";
}> = RecipeWrapper.signIn;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Sign in a user with email and password

Parameters

Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.shouldTryLinkingWithSessionUser? boolean
input.userContext? any

Returns

Promise< | { fetchResponse: Response; status: "OK"; user: User; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; } | { fetchResponse: Response; status: "WRONG_CREDENTIALS_ERROR"; } | { fetchResponse: Response; reason: string; status: "SIGN_IN_NOT_ALLOWED"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


signOut()

const signOut: (input?) => Promise<void> = RecipeWrapper.signOut;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Parameters

Parameter Type
input? { userContext?: any; }
input.userContext? any

Returns

Promise<void>


signUp()

const signUp: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
  user: User;
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}
  | {
  fetchResponse: Response;
  reason: string;
  status: "SIGN_UP_NOT_ALLOWED";
}> = RecipeWrapper.signUp;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Sign up a user with email and password

Parameters

Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; shouldTryLinkingWithSessionUser?: boolean; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.shouldTryLinkingWithSessionUser? boolean
input.userContext? any

Returns

Promise< | { fetchResponse: Response; status: "OK"; user: User; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; } | { fetchResponse: Response; reason: string; status: "SIGN_UP_NOT_ALLOWED"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"


submitNewPassword()

const submitNewPassword: (input) => Promise<
  | {
  fetchResponse: Response;
  status: "OK";
}
  | {
  fetchResponse: Response;
  status: "RESET_PASSWORD_INVALID_TOKEN_ERROR";
}
  | {
  fetchResponse: Response;
  formFields: object[];
  status: "FIELD_ERROR";
}> = RecipeWrapper.submitNewPassword;

Defined in: tmp/supertokens-web-js/lib/ts/recipe/emailpassword/index.ts

Submit a new password for the user

Parameters

Parameter Type
input { formFields: object[]; options?: RecipeFunctionOptions; userContext?: any; }
input.formFields object[]
input.options? RecipeFunctionOptions
input.userContext? any

Returns

Promise< | { fetchResponse: Response; status: "OK"; } | { fetchResponse: Response; status: "RESET_PASSWORD_INVALID_TOKEN_ERROR"; } | { fetchResponse: Response; formFields: object[]; status: "FIELD_ERROR"; }>

{status: "OK"} if successfull

Throws

STGeneralError if the API exposed by the backend SDKs returns status: "GENERAL_ERROR"

References

PostAPIHookContext

Re-exports PostAPIHookContext


PreAPIHookContext

Re-exports PreAPIHookContext


RecipeInterface

Re-exports RecipeInterface


UserInput

Re-exports UserInput

API reference

API schema and response details