fix: prevent unauthorized match winner setting and add state validation#112
Open
fix: prevent unauthorized match winner setting and add state validation#112
Conversation
Fix inverted permission checks in setMatchWinner and forfeitMatch that allowed non-organizers to set winners/forfeit while blocking organizers. Add match state validation to reject winner setting on matches that haven't started or already ended, and reject forfeiting ended matches. Closes #312
Replace duplicated terminal status strings across 4 locations in matches.controller.ts with shared static class constants.
lukepolo
reviewed
Mar 6, 2026
src/matches/matches.controller.ts
Outdated
| throw Error("match not found"); | ||
| } | ||
|
|
||
| if (MatchesController.TERMINAL_OR_PRE_START_STATUSES.includes(matchToSetWinner.status)) { |
Contributor
There was a problem hiding this comment.
you should be able to set the winner in any state
Contributor
Author
There was a problem hiding this comment.
should be fixed now, check latest commit
Remove state validation from setMatchWinner per review feedback — organizers should be able to set the winner regardless of match state. Remove unused TERMINAL_OR_PRE_START_STATUSES constant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setMatchWinnerandforfeitMatchthat allowed non-organizers to set winners/forfeit while blocking organizerssetMatchWinner— rejects matches in terminal states (Finished,Canceled,Forfeit,Tie,Surrendered) or pre-start states (Scheduled,PickingPlayers)forfeitMatch— rejects matches already in terminal statesCloses 5stackgg/5stack-panel#312
Test plan
WaitingForCheckIn,Veto,WaitingForServer,Live)