// GET /api/pam/active — current user's active grants

import { auth } from "@/auth";
import { listActiveGrants } 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 grants = await listActiveGrants(gscsid);
  return Response.json({ active: grants });
}
