Skip to content

Fix multiple backend and frontend bugs - #33

Closed
Uttam-Mahata wants to merge 1 commit into
mainfrom
fix/issues-3885314757463570572
Closed

Fix multiple backend and frontend bugs#33
Uttam-Mahata wants to merge 1 commit into
mainfrom
fix/issues-3885314757463570572

Conversation

@Uttam-Mahata

Copy link
Copy Markdown
Owner

Fixed multiple issues:

  1. Scoreboard: Updated the indexing logic to fallback to user ID when the submission doesn't have a team ID.
  2. Suspension: Enforce user suspensions in login based on the SuspendedUntil timestamp.
  3. Test Suite: Remove backend/docs from .gitignore and add generated Swagger documentation.
  4. Frontend OAuth: Fix duplicated /auth base paths in GitHub and Discord login flows.
  5. Contest Registration: Make contest HTTP client methods explicitly pass withCredentials to attach cookies.

PR created automatically by Jules for task 3885314757463570572 started by @Uttam-Mahata

… registration

- Fix scoreboard ignoring solo players
- Enforce SuspendedUntil logic in authentication
- Include missing Swagger docs for go test
- Fix incorrect OAuth backend URL paths
- Pass withCredentials for contest registration to send cookies

Co-authored-by: Uttam-Mahata <92252205+Uttam-Mahata@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings April 8, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR bundles several backend + frontend fixes across authentication, contest registration, and scoreboard computation, and also commits generated Swagger docs under backend/docs.

Changes:

  • Frontend: fixes OAuth redirect URLs for GitHub/Discord and ensures contest registration requests send cookies (withCredentials).
  • Backend: updates scoreboard indexing to handle submissions missing team_id, and blocks login when SuspendedUntil is in the future.
  • Repo hygiene: removes backend/docs/ from .gitignore and adds generated Swagger JSON/YAML.

Reviewed changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/app/services/contest.ts Adds withCredentials to contest registration endpoints so cookies/JWT are attached.
frontend/src/app/services/auth.ts Fixes duplicated /auth in GitHub/Discord OAuth redirect URLs.
backend/internal/services/scoreboard_service.go Adjusts solve indexing/scoring to handle submissions without TeamID.
backend/internal/services/auth_service.go Enforces temporary suspensions during username/password login.
backend/docs/swagger.yaml Adds generated Swagger spec (YAML).
backend/docs/swagger.json Adds generated Swagger spec (JSON).
.gitignore Stops ignoring backend/docs/ so generated docs can be committed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 200 to 208
for _, sub := range submissions {
if sub.TeamID == "" {
continue
entityID := sub.TeamID
if entityID == "" {
entityID = sub.UserID
}
tid := sub.TeamID
cid := sub.ChallengeID

if !contestTeams[tid] || !contestChallenges[cid] {
if (sub.TeamID != "" && !contestTeams[sub.TeamID]) || !contestChallenges[cid] {
continue

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildTeamChallengeFirstSolveIndex now falls back to sub.UserID when sub.TeamID is empty, but it still increments challengeSolveRank[cid]. This means a submission missing TeamID can consume an early solve-rank and reduce points awarded to legitimate team solves later (and can affect team scoreboard/progression since they reuse this function). Consider normalizing these submissions to the solver's team ID (if known) before ranking, or excluding TeamID-less submissions from the shared rank calculation used for team scoring.

Copilot uses AI. Check for mistakes.
Comment on lines +320 to 331
// Verify team registration only for team solves (tid is TeamID, not UserID).
// Since we don't have solverUID here yet, we will check it inside the loop.
for cid, solverUID := range chMap {
if tid != solverUID && !contestTeams[tid] {
continue
}
if !contestChallenges[cid] {
continue
}
if !registeredUserIDs[solverUID] {
if tid != solverUID && !registeredUserIDs[solverUID] {
continue
}

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In GetScoreboard, the registration checks are skipped when tid == solverUID (i.e., when the index key is a user ID from a TeamID-less submission). That allows unregistered users (or users not in a registered team) to appear on a contest scoreboard if their submissions lack TeamID. If these TeamID-less submissions are meant to be attributed to a team member of a registered team, the safer check is to still require registeredUserIDs[solverUID] (or map the submission to the user’s team) rather than bypassing registration entirely.

Copilot uses AI. Check for mistakes.
Comment on lines 186 to +198
// Check if user is banned
if user.Status == "banned" {
return "", nil, errors.New("your account has been banned")
}

// Check if user is suspended
if user.SuspendedUntil != "" {
if suspendedUntil, err := time.Parse(time.RFC3339, user.SuspendedUntil); err == nil {
if time.Now().Before(suspendedUntil) {
return "", nil, errors.New("your account is temporarily suspended")
}
}
}

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Login currently blocks only Status == "banned", but admin APIs allow setting status to "suspended" and there’s no visible handler updating suspended_until. As a result, users with status="suspended" (or with a malformed SuspendedUntil) can still log in. Consider explicitly denying login when user.Status == "suspended", and treating an invalid SuspendedUntil value as an error (or as suspended) instead of silently ignoring the parse failure.

Copilot uses AI. Check for mistakes.
@Uttam-Mahata
Uttam-Mahata deleted the fix/issues-3885314757463570572 branch April 12, 2026 14:12
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.

2 participants