import { KeyRound } from "lucide-react"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { Rotation } from "@/components/rotation/Rotation"; import { Breadcrumb } from "@/components/ui/Breadcrumb"; import { Button } from "@/components/ui/Button"; import { Leerzustand } from "@/components/ui/Leerzustand"; import { Seitenkopf } from "@/components/ui/Seitenkopf"; import { darf } from "@/server/auth/rechte"; import { sitzungErforderlich } from "@/server/auth/sitzungspflicht"; import { RotationsFehler, rotationsStand } from "@/server/services/rotation"; import { offeneEntfernungen } from "@/server/services/widerruf"; export const metadata: Metadata = { title: "Schlüssel rotieren" }; /** Gefuehrte Rotation (#023): Schrittfolge, wiederaufnehmbar. */ export default async function RotierenSeite({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; const { benutzer } = await sitzungErforderlich("schluesselVerwalten", `/schluessel/${id}/rotieren`); if (!darf(benutzer.rolle, "publicKeyAusrollen")) notFound(); let stand; try { stand = await rotationsStand(id); } catch (fehler) { if (fehler instanceof RotationsFehler) notFound(); throw fehler; } const { alt } = stand; const kopf = ( } titel={`„${alt.name}“ rotieren`} untertitel="Neuer Schlüssel an allen Stellen, testen, erst dann den alten entfernen." /> ); // Ohne Nachfolger und nicht rotierbar: nur der Hinweis, keine halbe Rotation. if (!stand.neu && stand.gesperrt) { return (
{kopf} } titel={stand.gesperrt.neuerPublicKeyNoetig ? "Neuer Public Key nötig" : "Nicht rotierbar"} text={stand.gesperrt.grund} aktion={} />
); } const widerruf = stand.neu && !stand.abgebrochen && alt.widerrufEingeleitetAm && alt.status !== "ROTIERT" ? await offeneEntfernungen([alt.id]) : null; // Abbruch (#032): solange der neue Schluessel nicht widerrufen ist, laeuft sein Widerruf hier weiter. const abbruch = stand.neu && stand.abgebrochen ? { offen: stand.neu.status === "WIDERRUFEN" ? null : await offeneEntfernungen([stand.neu.id]) } : null; return (
{kopf}
); }