admin管理员组

文章数量:1332345

How can I check if a user with the same email already exists when Enable email confirmations is turned on.

When Enable email confirmations are turned on an obfuscated / fake user object is returned by supabase, according to this ment it's a feature.

How can I check if the email already exists without turning off Email confirmation?

I tried passing using supabase.auth.api.getUser, but that needs JWT, not the user id.

How can I check if a user with the same email already exists when Enable email confirmations is turned on.

When Enable email confirmations are turned on an obfuscated / fake user object is returned by supabase, according to this ment it's a feature.

How can I check if the email already exists without turning off Email confirmation?

I tried passing using supabase.auth.api.getUser, but that needs JWT, not the user id.

Share Improve this question asked Sep 21, 2022 at 14:34 B45iB45i 2,6112 gold badges27 silver badges38 bronze badges 1
  • 1 interesting choice but according to github./supabase/supabase-js/issues/… you shouldn't need to check since the user is redirected via mail back to your application – zapl Commented Sep 21, 2022 at 16:42
Add a ment  | 

3 Answers 3

Reset to default 7

Not sure if following is the correct way but I do it as follows (TypeScript):

const [errorMsg, setErrorMsg] = useState<string | null>(null);
const [successMsg, setSuccessMsg] = useState<string | null>(null);

async function signUp(formData: Values) {
  const { data, error } = await supabase.auth.signUp({
    email: formData.email,
    password: formData.password,
  });

  if (error) {
    setErrorMsg(error.message);
  } else if (data.user?.identities?.length === 0) {
    setErrorMsg('User already registered');
  } else {
    setSuccessMsg('Success! Please check your inbox.');
  }
}

data.user?.identities?.length is 0 when the user is registered already.

Just go to providers and disable phone confirmation even if phone provider is disabled. Then you will get it in errors field. That user_already_exists

https://supabase./docs/reference/javascript/auth-signup

Going to the providers section and disabling phone confirmation fixes the issue, make sure to disable the phone confirmation and not just the phone provider, doing these will result in supabase finally giving the user already registered error.

Disabling The Phone Confirmation Under Providers (Phone)

本文标签: javascriptHow to check if user already exists in SupabaseStack Overflow