supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
2.86k stars 220 forks source link

Auth: different behavior of signUp() in local development #947

Closed 842u closed 3 months ago

842u commented 4 months ago

Bug report

Describe the bug

Developing localy with auth.email.enable_confirmations=true, calling signUp() for existing confirmed user responds with an error 'User already registered'. However, in production, signUp() behaves as expected: it succeeds and returns data, as mentioned in the docs:

  • If signUp() is called for an existing confirmed user:
    • If Confirm email is enabled in your project, an obfuscated/fake user object is returned.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Call signUp() first time const response = await supabase.auth.signUp({ email, password });

  2. Confirm email

  3. Call signUp() for existing confirmed email const response = await supabase.auth.signUp({ email, password });

  4. response will contain error but no data { data: { user: null, session: null }, error: { message: 'User already registered', status: 400 }}

Expected behavior

The behavior of signUp() will be the same in both local development and production.

System information

Additional context

https://github.com/supabase/supabase/issues/18195 might be connected.

842u commented 3 months ago

Problem

After some research it turns out that in GoTrue API signup there is a check not only if email confirmation is enabled but also if phose confirmation is enabled:

if config.Mailer.Autoconfirm || config.Sms.Autoconfirm {return badRequestError("User already registered")}

Following this, there are gaps in documentation and inconsistencies in default configurations when using Supabase platform compared to self-hosting Supabase manualy with Docker or using Supabase CLI.

Default configurations: