import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { Container, SectionHeading, Button, FormPanel } from "@/components/ui"; import { BackLink } from "@/components/back-link"; import { ShieldIcon } from "@/components/account-ui"; import { PasswordField } from "@/components/password-field"; import { getCurrentCustomer } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import { startTwoFactorSetupAction, disableTwoFactorAction } from "../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export const metadata: Metadata = { title: "Zwei-Faktor-Authentifizierung" }; export const dynamic = "force-dynamic"; export default async function ZweiFaktorPage() { const t = getDictionary(await getLocale()); const customer = await getCurrentCustomer(); if (!customer) redirect("/konto"); const remainingBackupCodes = customer.twoFactorEnabled ? await prisma.twoFactorBackupCode.count({ where: { customerId: customer.id, usedAt: null } }) : 0; return (
{customer.twoFactorEnabled ? (

{t.twoFactorPage.activeStatus(remainingBackupCodes)}

{t.twoFactorPage.disableHeading}

) : (
)}
); }