// 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 { id?: string } | undefined;
  if (!user?.id) return Response.json({ error: "unauthorized" }, { status: 401 });
  const grants = await listActiveGrants(user.id);
  return Response.json({ active: grants });
}
