feat: account deletion

This commit is contained in:
trafficlunar 2025-04-10 22:52:18 +01:00
parent 96e12d0716
commit d2522c8d93
3 changed files with 117 additions and 5 deletions

View file

@ -0,0 +1,20 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
export async function DELETE() {
const session = await auth();
if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
try {
await prisma.user.delete({
where: { id: Number(session.user?.id!) },
});
} catch (error) {
console.error("Failed to delete user:", error);
return NextResponse.json({ error: "Failed to delete account" }, { status: 500 });
}
return NextResponse.json({ success: true });
}