Skip to content

Email Authentication

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

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.

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.

Promise<void>

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

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

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.

Promise<void>

const completeEmailAuth = await sdk.auth.email.complete({
otpCode: 'OTP_CODE',
})