diff options
Diffstat (limited to 'apps/web/app/api/account/route.ts')
| -rw-r--r-- | apps/web/app/api/account/route.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/web/app/api/account/route.ts b/apps/web/app/api/account/route.ts new file mode 100644 index 0000000..6b1bc2d --- /dev/null +++ b/apps/web/app/api/account/route.ts @@ -0,0 +1,27 @@ +import { NextResponse } from "next/server" +import { createSupabaseServerClient } from "@/lib/supabase/server" +import { createSupabaseAdminClient } from "@/lib/supabase/admin" + +export async function DELETE() { + const supabaseClient = await createSupabaseServerClient() + const { + data: { user }, + } = await supabaseClient.auth.getUser() + + if (!user) { + return NextResponse.json({ error: "Not authenticated" }, { status: 401 }) + } + + const adminClient = createSupabaseAdminClient() + + const { error } = await adminClient.auth.admin.deleteUser(user.id) + + if (error) { + return NextResponse.json( + { error: "Failed to delete account" }, + { status: 500 } + ) + } + + return new Response(null, { status: 204 }) +} |