// GET /api/pam/audit — current user's recent privilege audit entries

import { auth } from "@/auth";
import { listAudit } from "@/lib/pam";

export const dynamic = "force-dynamic";

export async function GET() {
  const session = await auth();
  const user = session?.user as { gscSid?: string } | undefined;
  const gscsid = user?.gscSid;
  if (!gscsid) return Response.json({ error: "unauthorized" }, { status: 401 });
  const rows = await listAudit(gscsid, 100);
  return Response.json({ audit: rows });
}
