Create API to delete anonymous accuont
This commit is contained in:
parent
2078b6ed4d
commit
281d99a4da
1 changed files with 15 additions and 0 deletions
15
src/pages/api/account/anon-delete.ts
Normal file
15
src/pages/api/account/anon-delete.ts
Normal 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")
|
||||
}
|
Loading…
Reference in a new issue