Skip to Content
AuthEmail

Email Authentication

After instantiating the SDK (which is explained here), you’re allowed to use the following methods from auth.email.

Initiate email authentication

When the initialize method is called, an email is sent to the specified address. The email will contain either a one-time code or a link, depending on the authentication method selected in the fourt.io dashboard.

initialize()

Parameters

EmailInitializeAuthParams object containing:

  • email - The email address of the user who wants to authenticate.
  • redirectUrl (optional) - The URL to which the user will be redirected after completing the authentication process. It only needs to be provided if you are using link-based authentication.

Returns

Promise<void>

Example

const initializeEmailAuth = await sdk.auth.email.initialize({ email: 'user-email@test.com', redirectUrl: 'https://fourt.io', })

Complete email authentication

When the complete method is called, the authentication process is finalized using the parameters received.

complete()

Parameters

CompleteEmailAuthParams object containing:

  • email - The email address of the user who wants to authenticate.
  • otpCode - The one-time code sent to the user’s email.

Returns

Promise<void>

Example

const completeEmailAuth = await sdk.auth.email.complete({ email: 'user-email@test.com', otpCode: 'OTP_CODE', })