Skip to content

BaseballHelm: derive Discover map count scope server-side #404

Description

@njrini99-code

Finding

getStateCounts trusts caller-supplied coachId and coachType even though it is exported as a server action and affects Discover map visibility.

Evidence

  • src/app/baseball/actions/discover.ts lines 594-596 warns that the caller must derive coachType from the authenticated session.
  • Lines 598-602 export getStateCounts(mode, coachId, coachType) directly as a server action.
  • Lines 605-617 gate eligible player types based on the supplied coachType parameter.
  • src/app/baseball/(dashboard)/dashboard/discover/DiscoverClient.tsx lines 320-321 passes client auth state into the action. A direct action call can supply a different coach type.
  • getDiscoverPlayers and getDiscoverTeams correctly derive coach identity/type server-side, so this is a one-off mismatch in the map counts lane.

Why this matters

The map should reflect the same recruiting boundaries as the player/team lists. If counts can be requested with a forged coach type, the UI can reveal availability signals for player/org categories the coach should not recruit.

Acceptance criteria

  • Remove coachId and coachType parameters from the exported action; derive both from supabase.auth.getUser() and the coach row server-side.
  • Reuse the same coach-type eligibility helper as getDiscoverPlayers and getDiscoverTeams.
  • Add tests that high-school/showcase coaches get empty counts and JUCO coaches do not see JUCO-player or showcase/JUCO-team counts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    baseballBaseballHelmbugIncorrect behavior or regressionfixed-in-pr-421Verified fixed by PR #421; auto-closes on mergesecurityAuth, secrets, RLS, PII, webhooks

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions