How to handle email already exist
Stack: Typescript, Expo, React Native
i want to throw error when email already exist in the auth, how do you guys handle that one with supabase auth
const handleSignup = async () => {
if (
name.length < 1 ||
email.length < 1 ||
password.length < 1 ||
repeatPassword.length < 1
) {
setError('All fields are required');
} else if (!isEmailValid(email)) {
setError('Invalid Email Address')
} else if (password !== repeatPassword) {
setError('Passwords do not match');
} else {
const { data, error } = await supabase.auth.signUp({
email: email,
password: password,
options: {
data: {
fullname: name,
},
},
})
setIsLoading(true)
if (error) {
setError(error?.message)
console.error('Signup Error: ', error?.message)
} else {
navigation.navigate('Code', {
email_address: email,
});
console.log('Signup: ', data)
}
setIsLoading(false)
}
} const handleSignup = async () => {
if (
name.length < 1 ||
email.length < 1 ||
password.length < 1 ||
repeatPassword.length < 1
) {
setError('All fields are required');
} else if (!isEmailValid(email)) {
setError('Invalid Email Address')
} else if (password !== repeatPassword) {
setError('Passwords do not match');
} else {
const { data, error } = await supabase.auth.signUp({
email: email,
password: password,
options: {
data: {
fullname: name,
},
},
})
setIsLoading(true)
if (error) {
setError(error?.message)
console.error('Signup Error: ', error?.message)
} else {
navigation.navigate('Code', {
email_address: email,
});
console.log('Signup: ', data)
}
setIsLoading(false)
}
}i want to throw error when email already exist in the auth, how do you guys handle that one with supabase auth