Conditionally prevent signup with email otp?

In my app I want to support both the signin and signup via email OTP. However my app needs the user to go through an onboarding before he can create a new account so I would like to be able to pass a parameter that determines if this request can create a new user or not.

  const onSignUpPress = async (enableAccountCreation: boolean) => {
    const { data, error } = await authClient.emailOtp.sendVerificationOtp({
      email: emailAddress,
      //maybe add a signup type to allow account creation?
      type: enableAccountCreation? 'sign-up' : 'sign-in', 
    });
    if (error) return;
    setPendingVerification(true);
  };
Was this page helpful?