Add non-destructive dev seed on startup
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"use server";
|
||||
|
||||
import { requireKitaSession } from "@/lib/auth-utils";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { signOut } from "@/auth"; // Note: this is NextAuth v5 server side signOut if needed, but we do client side
|
||||
|
||||
export async function deleteMyAccount() {
|
||||
const session = await requireKitaSession();
|
||||
|
||||
try {
|
||||
// Da wir onDelete: Cascade überall konfiguriert haben,
|
||||
// löscht dieser eine Befehl den User, seine ChildParent-Links,
|
||||
// seine MitbringselItems, seine NotdienstAvailabilities etc.
|
||||
await prisma.user.delete({
|
||||
where: {
|
||||
id: session.user.id,
|
||||
},
|
||||
});
|
||||
|
||||
// The client component will trigger the actual NextAuth client signOut,
|
||||
// but returning success indicates the DB deletion was successful.
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Löschen des Accounts:", error);
|
||||
return { error: "Ein Fehler ist beim Löschen aufgetreten." };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user