Search code examples
typescriptnext.jssupabase

How to use captcha token with signInWithPassword of supabase?


I have users trying to mass-sign-in to my system I build and authenticate with supabase. and they do have support for captcha token like hCaptcha. but i can't figure out how to use the token for a sign in with password method?

Here's is the code i've found in their documentation:

supabase.auth.signInWithPassword({
    email,
    password,
  });

help!!

I read their docs, ask in their community but in vain


Solution

  • here's is an example, i've also add a check for dev env as the captch don't work for localhost:

      const signInObject:SignInObject = {
        email,
        password,
        options: {}
      };
    
      if(!isDev() && captchaToken) {
        signInObject.options = {
          captchaToken
        };
      }
    
      const { error } = await supabase.auth.signInWithPassword(signInObject);
    
    

    sometime i used gpteachus to learn about nextjs and supabase and it help me with this problem. anyway, good luck!!