Create API to delete anonymous accuont

This commit is contained in:
Korbs 2024-07-17 19:05:22 -04:00
parent 2078b6ed4d
commit 281d99a4da

View file

@ -0,0 +1,15 @@
import type { APIRoute } from "astro"
import { supabase } from "@library/supabase"
export const POST: APIRoute = async ({ cookies, redirect }) => {
// https://supabase.com/docs/reference/javascript/auth-updateuser?example=update-the-users-metadata
const { error } = await supabase.rpc('delete_user');
cookies.delete("anonymous-session", { path: "/" })
if (error) {
return new Response(error.message, { status: 500 })
}
return redirect("/api/auth/signout")
}