import { Suspense } from "react"; import Link from "next/link"; import { verifySessionToken } from "@/lib/admin-auth"; import { getAuditLogs } from "@/lib/audit-log"; import { cookies } from "next/headers"; import { AdminNav } from "@/components/admin/AdminNav"; async function AuditLogsContent() { const cookieStore = await cookies(); const token = cookieStore.get("admin_session")?.value; if (!token) { return (

Nicht authentifiziert

Zurück zum Login
); } const session = await verifySessionToken(token); if (!session) { return (

Session abgelaufen

Erneut anmelden
); } const logs = await getAuditLogs({ limit: 100, offset: 0 }); const successCount = logs.filter((l) => l.success).length; const failedCount = logs.filter((l) => !l.success).length; const uniqueIps = new Set(logs.map((l) => l.ip_addr)).size; const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000).toISOString(); const recentLogs = logs.filter((l) => l.timestamp > oneHourAgo); const recentFailed = recentLogs.filter((l) => !l.success).length; return (

Audit-Logs

Login-Aktivitäten und Sicherheitsereignisse

{[ { label: "Erfolgreich (Gesamt)", wert: successCount, color: "text-green-400" }, { label: "Fehlgeschlagen (Gesamt)", wert: failedCount, color: "text-red-400" }, { label: "Fehlgeschlagen (1h)", wert: recentFailed, color: recentFailed >= 5 ? "text-red-400" : "text-green-400" }, { label: "Eindeutige IPs", wert: uniqueIps, color: "text-white" }, ].map((k) => (
{k.label}
{k.wert}
))}
{recentFailed >= 5 && (

⚠️ Verdächtige Aktivität erkannt

{recentFailed} fehlgeschlagene Login-Versuche in der letzten Stunde

)}
{logs.length === 0 ? ( ) : ( logs.map((log) => ( )) )}
Zeitstempel E-Mail IP-Adresse Status Grund
Keine Audit-Logs vorhanden
{new Date(log.timestamp).toLocaleString("de-DE")} {log.email} {log.ip_addr} {log.success ? "✓ Erfolgreich" : "✗ Fehlgeschlagen"} {log.reason ? formatReason(log.reason) : "–"}

Hinweis: Detaillierte Geräte-Informationen sind in der Supabase-Tabelle{" "} admin_audit_logs {" "} gespeichert.

); } function formatReason(reason: string): string { const reasons: Record = { invalid_password: "Falsches Passwort", user_not_found_or_inactive: "User nicht gefunden / inaktiv", missing_credentials: "Fehlende Anmeldedaten", invalid_token: "Ungültiger Token", token_expired: "Token abgelaufen", }; return reasons[reason] || reason; } export default function AuditLogsPage() { return (

Lädt Audit-Logs…

} >
); }