73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { UserRole } from "@prisma/client";
|
|
|
|
import { requireSession } from "@/lib/auth-utils";
|
|
import { prisma } from "@/lib/prisma";
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card";
|
|
|
|
export const metadata = { title: "Datenschutz-Einwilligung · Kita-Planer" };
|
|
|
|
// Diese Seite wird nur in einem sehr seltenen Edge-Case erreicht:
|
|
// Ein User mit kitaId hat noch kein `privacyPolicyAcceptedAt` gesetzt
|
|
// (z.B. über einen alten Seed oder manuellen DB-Eintrag).
|
|
// Im normalen Registrierungs-Flow wird die Einwilligung bereits
|
|
// in registerAction() zum Zeitpunkt der Kontoerstellung erfasst.
|
|
|
|
export default async function ConsentPage() {
|
|
const session = await requireSession();
|
|
|
|
// SUPERADMIN benötigt keinen Consent-Flow — hat keinen Kita-Kontext.
|
|
if (session.user.role === UserRole.SUPERADMIN) {
|
|
redirect("/admin");
|
|
}
|
|
|
|
// User ohne kitaId gehört in den Onboarding-Wizard.
|
|
if (!session.user.kitaId) {
|
|
redirect("/onboarding");
|
|
}
|
|
|
|
// Prüfen, ob der Consent wirklich fehlt (DB-seitiger Check).
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: session.user.id },
|
|
select: { privacyPolicyAcceptedAt: true },
|
|
});
|
|
|
|
// Consent bereits vorhanden → weiter ins Dashboard.
|
|
if (user?.privacyPolicyAcceptedAt) {
|
|
redirect("/dashboard");
|
|
}
|
|
|
|
return (
|
|
<div className="flex min-h-screen items-center justify-center bg-muted/30 px-4 py-12">
|
|
<Card className="w-full max-w-md">
|
|
<CardHeader className="space-y-2">
|
|
<CardTitle>Datenschutz-Einwilligung erforderlich</CardTitle>
|
|
<CardDescription>
|
|
Dein Konto wurde ohne Datenschutz-Einwilligung angelegt. Bitte
|
|
wende dich an deinen Kita-Administrator oder den Support, um deinen
|
|
Account zu reaktivieren.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="text-sm text-muted-foreground">
|
|
<p>
|
|
Falls du glaubst, dass dies ein Fehler ist, kontaktiere bitte{" "}
|
|
<a
|
|
href="mailto:support@kita-planer.de"
|
|
className="font-medium text-foreground underline"
|
|
>
|
|
support@kita-planer.de
|
|
</a>
|
|
.
|
|
</p>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|