Torio
Torio
DTDrizzle Team
Created by Torio on 6/30/2024 in #help
I want to create Auth with Supabase and drizzle-orm.
Can someone please tell me how to do this?
export async function signup(formData:FormData){
const supabase=createClient()

const formUserData={
email:formData.get('email') as string,
password:formData.get('password') as string
}

const {data:{user},error}=await supabase.auth.signUp(formUserData)

console.log('signUp')
console.log(user)
if(error||!user?.id||!user){
redirect('/error')
}

const existingAccount=await getAccount(formUserData.email);
if (existingAccount!==undefined){
console.log('existingAccount')
revalidatePath('/',"layout")
redirect("/");
}


await db.insert(testAccounts).values({
email: formUserData.email,
password: formUserData.password,
userId: user.id

})

revalidatePath('/','layout')
redirect('/private')
}
export async function signup(formData:FormData){
const supabase=createClient()

const formUserData={
email:formData.get('email') as string,
password:formData.get('password') as string
}

const {data:{user},error}=await supabase.auth.signUp(formUserData)

console.log('signUp')
console.log(user)
if(error||!user?.id||!user){
redirect('/error')
}

const existingAccount=await getAccount(formUserData.email);
if (existingAccount!==undefined){
console.log('existingAccount')
revalidatePath('/',"layout")
redirect("/");
}


await db.insert(testAccounts).values({
email: formUserData.email,
password: formUserData.password,
userId: user.id

})

revalidatePath('/','layout')
redirect('/private')
}
When I run this code, data doesn't have user data.
1 replies