Options
All
  • Public
  • Public/Protected
  • All
Menu

These are the SDK reference docs. If you’re looking for docs to implement SuperTokens, you might want to check out the User Guides

Module recipe/emailpassword

Index

Type aliases

PostAPIHookContext

PostAPIHookContext: RecipePostAPIHookContext<PreAndPostAPIHookAction>

PreAPIHookContext

PreAPIHookContext: RecipePreAPIHookContext<PreAndPostAPIHookAction>

RecipeFunctionOptions

RecipeFunctionOptions: { preAPIHook?: any }

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

Type declaration

  • preAPIHook?:function
    • preAPIHook(input: { requestInit: RequestInit; url: string; userContext: any }): Promise<{ requestInit: RequestInit; url: string }>
    • Parameters

      • input: { requestInit: RequestInit; url: string; userContext: any }
        • requestInit: RequestInit
        • url: string
        • userContext: any

      Returns Promise<{ requestInit: RequestInit; url: string }>

RecipeInterface

RecipeInterface: { doesEmailExist: any; getResetPasswordTokenFromURL: any; sendPasswordResetEmail: any; signIn: any; signUp: any; submitNewPassword: any }

Type declaration

  • doesEmailExist:function
    • doesEmailExist(input: { email: string; options?: RecipeFunctionOptions; userContext: any }): Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>
    • Check if an email exists

      throws

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

      Parameters

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

      {status: "OK", doesExist: boolean}

  • getResetPasswordTokenFromURL:function
    • getResetPasswordTokenFromURL(input: { userContext: any }): string
    • Reads and returns the reset password token from the current URL

      Parameters

      • input: { userContext: any }
        • userContext: any

      Returns string

      The "token" query parameter from the current location

  • sendPasswordResetEmail:function
    • sendPasswordResetEmail(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext: any }): Promise<{ fetchResponse: Response; status: "OK" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>
    • Send an email to the user for password reset

      throws

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

      Parameters

      Returns Promise<{ fetchResponse: Response; status: "OK" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>

      {status: "OK"} if successfull

  • signIn:function
    • signIn(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext: any }): Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" } | { fetchResponse: Response; status: "WRONG_CREDENTIALS_ERROR" }>
    • Sign in a user with email and password

      throws

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

      Parameters

      Returns Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" } | { fetchResponse: Response; status: "WRONG_CREDENTIALS_ERROR" }>

      {status: "OK"} if successfull

  • signUp:function
    • signUp(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext: any }): Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>
    • Sign up a user with email and password

      throws

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

      Parameters

      Returns Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>

      {status: "OK"} if successfull

  • submitNewPassword:function
    • submitNewPassword(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext: any }): Promise<{ fetchResponse: Response; status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>
    • Submit a new password for the user

      throws

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

      Parameters

      Returns Promise<{ fetchResponse: Response; status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>

      {status: "OK"} if successfull

UserInput

UserInput: { override?: { functions?: any } } & RecipeModuleUserInput<PreAndPostAPIHookAction>

UserType

UserType: { email: string; id: string; timeJoined: number }

Type declaration

  • email: string
  • id: string
  • timeJoined: number

Functions

Const doesEmailExist

  • doesEmailExist(input: { email: string; options?: RecipeFunctionOptions; userContext?: any }): Promise<{ doesExist: boolean; fetchResponse: Response; status: "OK" }>

Const getResetPasswordTokenFromURL

  • getResetPasswordTokenFromURL(input?: { userContext?: any }): string

Const init

  • init(config?: UserInput): CreateRecipeFunction<PreAndPostAPIHookAction>

Const sendPasswordResetEmail

  • sendPasswordResetEmail(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>
  • Parameters

    • input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }
      • formFields: { id: string; value: string }[]
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

    Returns Promise<{ fetchResponse: Response; status: "OK" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>

Const signIn

  • signIn(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" } | { fetchResponse: Response; status: "WRONG_CREDENTIALS_ERROR" }>
  • Parameters

    • input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }
      • formFields: { id: string; value: string }[]
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

    Returns Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" } | { fetchResponse: Response; status: "WRONG_CREDENTIALS_ERROR" }>

Const signOut

  • signOut(input?: { userContext?: any }): Promise<void>

Const signUp

  • signUp(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK"; user: UserType } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>

Const submitNewPassword

  • submitNewPassword(input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }): Promise<{ fetchResponse: Response; status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>
  • Parameters

    • input: { formFields: { id: string; value: string }[]; options?: RecipeFunctionOptions; userContext?: any }
      • formFields: { id: string; value: string }[]
      • Optional options?: RecipeFunctionOptions
      • Optional userContext?: any

    Returns Promise<{ fetchResponse: Response; status: "OK" | "RESET_PASSWORD_INVALID_TOKEN_ERROR" } | { fetchResponse: Response; formFields: { error: string; id: string }[]; status: "FIELD_ERROR" }>

Generated using TypeDoc