signinwithotp

has this changed for creating new users? before new user was created if they did not have an account. now it seems not functioning?

i try many times. here my code:

export const signIn = async (email) => {
console.log("signing in attempt")
if (!email) {
alert("Please enter your email.");
return;
}
try {

await createUser(email)

let { data, error } = await supabase.auth.signInWithOtp({email})
if (error) {
console.error(error);
}
} catch (error) {
console.error(error);
}
};

export const signOut = async () => {
try {
const { error } = await supabase.auth.signOut();
if (error) throw error;
} catch (error) {
alert(error.error_description || error.message);
}
};


export const createUser = async (email) => {
let { data: existingUser, error } = await supabase
.from('users')
.select('email')
.eq('email', email)
.single()

if (error) {
console.error(error);
return;
}

if (!existingUser) {
const { data, error } = await supabase
.from('users')
.insert({ email });

if (error) {
console.error(error);
} else {
if (typeof window !== 'undefined') {
localStorage.setItem('userInDB', true)
}
}
}
}
Was this page helpful?