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
.
- 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
3 Answers
Reset to default 7Not 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)