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.
Finding
getStateCountstrusts caller-suppliedcoachIdandcoachTypeeven though it is exported as a server action and affects Discover map visibility.Evidence
src/app/baseball/actions/discover.tslines 594-596 warns that the caller must derivecoachTypefrom the authenticated session.getStateCounts(mode, coachId, coachType)directly as a server action.coachTypeparameter.src/app/baseball/(dashboard)/dashboard/discover/DiscoverClient.tsxlines 320-321 passes client auth state into the action. A direct action call can supply a different coach type.getDiscoverPlayersandgetDiscoverTeamscorrectly 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
coachIdandcoachTypeparameters from the exported action; derive both fromsupabase.auth.getUser()and the coach row server-side.getDiscoverPlayersandgetDiscoverTeams.