From 2242adc011a18af9a71ed57bea53bd830d4cb9bd Mon Sep 17 00:00:00 2001 From: jessy-david-dev Date: Fri, 10 Apr 2026 19:24:12 +0200 Subject: [PATCH] feat(profile): add account deletion with confirmation and update privacy policy --- app/api/account/route.ts | 14 ++++++++++ app/components/ProfileScreen.tsx | 47 ++++++++++++++++++++++++++++++++ app/privacy/page.tsx | 6 +++- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 app/api/account/route.ts diff --git a/app/api/account/route.ts b/app/api/account/route.ts new file mode 100644 index 0000000..1466111 --- /dev/null +++ b/app/api/account/route.ts @@ -0,0 +1,14 @@ +import { NextResponse } from "next/server"; +import { auth } from "../../../auth"; +import { prisma } from "../../../lib/prisma"; + +export async function DELETE() { + const session = await auth(); + if (!session?.user?.id) { + return NextResponse.json({ error: "Non connecté" }, { status: 401 }); + } + + await prisma.user.delete({ where: { id: session.user.id } }); + + return NextResponse.json({ ok: true }); +} diff --git a/app/components/ProfileScreen.tsx b/app/components/ProfileScreen.tsx index c7e4539..6259ed6 100644 --- a/app/components/ProfileScreen.tsx +++ b/app/components/ProfileScreen.tsx @@ -46,6 +46,15 @@ export function ProfileScreen({ userName, onBack }: { userName: string; onBack: const [games, setGames] = useState([]); const [loading, setLoading] = useState(true); const [filter, setFilter] = useState<"all" | "solo" | "multi">("all"); + const [confirmDelete, setConfirmDelete] = useState(false); + const [deleting, setDeleting] = useState(false); + + async function handleDeleteAccount() { + setDeleting(true); + await fetch("/api/account", { method: "DELETE" }); + await signOut({ redirect: false }); + onBack(); + } useEffect(() => { fetch("/api/games") @@ -160,6 +169,44 @@ export function ProfileScreen({ userName, onBack }: { userName: string; onBack: ))} + + {/* Danger zone */} +
+

Zone dangereuse

+ {!confirmDelete ? ( +
+

Supprime définitivement ton compte et toutes tes parties.

+ +
+ ) : ( +
+

+ ⚠ Cette action est irréversible. Toutes tes données seront supprimées. +

+
+ + +
+
+ )} +
); } diff --git a/app/privacy/page.tsx b/app/privacy/page.tsx index c132ec7..8dfe92d 100644 --- a/app/privacy/page.tsx +++ b/app/privacy/page.tsx @@ -74,7 +74,11 @@ export default function PrivacyPage() {

Vous pouvez à tout moment :