Skip to content

fix: stop exposing invite codes and emails to non-members - #809

Open
krish858 wants to merge 1 commit into
AOSSIE-Org:mainfrom
krish858:fix/team-info-exposure
Open

krish858 wants to merge 1 commit into
AOSSIE-Org:mainfrom
krish858:fix/team-info-exposure

Conversation

@krish858

@krish858 krish858 commented Nov 20, 2026 •

Copy link
Copy Markdown

Addressed Issues:

Fixes #807

Screenshots/Recordings:

Before – GET /teams/available returns the invite code, captain email and every member's email to any logged-in user:

image

After – GET /teams/available returns only public fields (no code, captainEmail or email):

image

After – Available Teams card shows the team leader's name instead of their email:

image

After – GET /teams/<another team's id> as a non-member returns 403:

image

Additional Notes:

Problem: GET /teams/available sent every open team in full (invite code, captain email, all members' emails) to any logged-in user, and GET /teams/:id returned the full team for any ID without checking membership.

Backend

  • models/team.go: added TeamSummary / TeamSummaryMember (id, name, captainId, captainName, members with userId/displayName/avatarUrl/elo, maxSize, averageElo — no code, no emails), plus Team.Summary() and Team.HasMember().
  • controllers/team_controller.go:
    • GetAvailableTeams now returns []TeamSummary.
    • GetTeam returns 403 to non-members; members still get the full team.

Frontend

  • services/teamService.ts: added TeamSummary types; getAvailableTeams() returns TeamSummary[].
  • Pages/TeamBuilder.tsx: the Available Teams card shows the team leader's name instead of their email.

Not affected: your own teams (/teams/user/teams still includes the invite code for members), join by ID, join by code, member profiles and team matchmaking. GET /teams/:id has no callers in the frontend or backend.

How to verify

  1. Create a team as user A; log in as user B and open Team Builder.
  2. Network tab: /teams/available contains no code, captainEmail or email.
  3. The Available Teams card shows the leader's name; Join and Join by Code still work.
  4. As B, GET /teams/<A's team id> → 403; as A → full team.

Checks run: go build ./..., go vet ./..., go test ./..., npm test, npm run build all pass. npm run lint reports 9 errors in TeamBuilder.tsx that already exist on main; this PR adds none.

AI Usage Disclosure:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: Claude Opus 5.5 (Anthropic), used to review the affected code paths, draft the backend/frontend changes. I reviewed every change, ran it locally in Docker, and verified the endpoint responses and UI manually.

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features

    • Available-team listings now show captain names and member display names, avatars, and ratings.
  • Bug Fixes

    • Full team details are now limited to authenticated team members; unauthenticated requests receive an authentication error, and non-members are denied access.
    • Available-team listings no longer expose member email addresses or team invite codes.

Signed-off-by: krish858 <unknowmortal57@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The API now checks team membership before returning full team details and returns reduced summaries for available teams. The frontend uses the summary types and displays captain names instead of email addresses.

Changes: Team response privacy

Layer / File(s) Summary
Team summary contract
backend/models/team.go
TeamSummaryMember and TeamSummary expose selected team and member fields. Team.Summary builds the summary, and Team.HasMember checks member IDs.
Team endpoint responses
backend/controllers/team_controller.go
GetTeam requires an authenticated team member and returns 401 or 403 when the requester fails the checks. GetAvailableTeams returns team summaries.
Available-team frontend integration
frontend/src/services/teamService.ts, frontend/src/Pages/TeamBuilder.tsx
The service and page use summary types. Available-team cards display the captain name, with “Team leader” as the fallback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 808 requests private teams and approval of join requests. This PR restricts access to full team details, but does not change joining by ID or code or add approval handling.

Suggested reviewers: rixitgithub, shreyas-gowda26

Merge Risk: Minimal · up to 24f7f

Non-members no longer receive invite codes or member emails from the available-teams list, and the full team record is limited to members. Members can still reach their team, and the frontend shows the captain's name. No outstanding merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed G'day, this title is spot on. It names the main change: the PR stops exposing invite codes and member emails to non-members. The diff adds public summary types without emails or invite codes, makes GE…
Linked Issues check Passed Directly linked issue #807 has two coding requirements. (1) GET /teams/available must not return invite codes or member emails. (2) GET /teams/:id must not return full team data to non-members.

Requi…
Out of Scope Changes check Passed All changed areas support the #807 objective. The backend changes in models/team.go (TeamSummary, TeamSummaryMember, Summary, HasMember) and controllers/team_controller.go (GetAvailableTeams, GetTeam)…
Full details: Title check

Explanation

G'day, this title is spot on. It names the main change: the PR stops exposing invite codes and member emails to non-members. The diff adds public summary types without emails or invite codes, makes GET /teams/:id require membership, and switches GET /teams/available to summaries. The title is short, clear and specific, so it passes.

Full details: Linked Issues check

Explanation

Directly linked issue #807 has two coding requirements. (1) GET /teams/available must not return invite codes or member emails. (2) GET /teams/:id must not return full team data to non-members.

Requirement 1 [#807]: models/team.go adds TeamSummary and TeamSummaryMember. These types have no code, captainEmail, or email fields. Team.Summary() builds them from the stored team. The raw summary states that GetAvailableTeams now returns []TeamSummary from team.Summary(). The reviewed head shows the model side. The GetAvailableTeams function body was cut off in my read of team_controller.go, so I rely on the summary for that function. The frontend teamService.ts types and TeamBuilder.tsx show captainName instead of captainEmail.

Requirement 2 [#807]: In controllers/team_controller.go, GetTeam returns 401 when userID is missing. It returns 403 when Team.HasMember(requesterID) is false. Members still receive the full team. The HasMember check in models/team.go compares member UserID values to the requester ObjectID.

No unmet coding requirement is found. The issue has no non-coding acceptance criteria. The PR does not add automated tests. The issue does not require tests, so this does not fail the check.

Full details: Out of Scope Changes check

Explanation

All changed areas support the #807 objective. The backend changes in models/team.go (TeamSummary, TeamSummaryMember, Summary, HasMember) and controllers/team_controller.go (GetAvailableTeams, GetTeam) limit exposed fields and enforce membership. The frontend changes in services/teamService.ts and Pages/TeamBuilder.tsx update the available-teams types and replace the displayed captain email with captainName. This is needed because the API no longer returns captainEmail. The PR description says that /teams/user/teams, join by ID, join by code, member profiles, and matchmaking are unchanged. The diff does not show unrelated changes. Unverified: the GetAvailableTeams body and the frontend files were read from summaries, not full diffs, because the controller read was truncated.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f90d2cc-414a-445e-be51-d02169005659
Commits

Reviewing files that changed from the base of the PR and between 95b24b5 and 24f7f14.

Files selected for processing: 4

  • backend/controllers/team_controller.go
  • backend/models/team.go
  • frontend/src/Pages/TeamBuilder.tsx
  • frontend/src/services/teamService.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@krish858

Copy link
Copy Markdown
Author

hi @Ri1tik , do these changes looks good ?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: User emails are visible to any logged-in user

1 participant