Skip to content

Commit

Permalink
allow anyone to set their bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
reteps committed Sep 8, 2024
1 parent 0a33d22 commit e979302
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions CTFd/schemas/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,11 @@ def validate_bracket_id(self, data):
if bracket_id is None:
return

current_user = get_current_user()
if is_admin():
bracket = Brackets.query.filter_by(id=bracket_id, type="users").first()
if bracket is None:
ValidationError(
"Please provide a valid bracket id", field_names=["bracket_id"]
)
else:
if (
current_user.bracket_id == int(bracket_id)
or current_user.bracket_id is None
):
bracket = Brackets.query.filter_by(id=bracket_id, type="users").first()
if bracket is None:
ValidationError(
"Please provide a valid bracket id", field_names=["bracket_id"]
)
else:
raise ValidationError(
"Please contact an admin to change your bracket",
field_names=["bracket_id"],
)
bracket = Brackets.query.filter_by(id=bracket_id, type="users").first()
if bracket is None:
ValidationError(
"Please provide a valid bracket id", field_names=["bracket_id"]
)

@pre_load
def validate_fields(self, data):
Expand Down

0 comments on commit e979302

Please sign in to comment.