import { auth } from "@/auth";
import { canAccessEvaluation } from "@/lib/evaluation-access";

export type ActionResult<T = void> = { success: true; data?: T } | { success: false; error: string };

export async function requireAuth() {
  const session = await auth();
  if (!session?.user) return null;
  return session;
}

export async function requireEvaluationAccess(evaluationId: string, userId: string, isAdmin: boolean) {
  const hasAccess = await canAccessEvaluation(evaluationId, userId, isAdmin);
  return hasAccess;
}
