diff --git a/CTFd/forms/config.py b/CTFd/forms/config.py index aee30b12..51ba3d56 100644 --- a/CTFd/forms/config.py +++ b/CTFd/forms/config.py @@ -33,8 +33,15 @@ class AccountSettingsForm(BaseForm): "Account Email Whitelist", description="Comma-seperated email domains which users can register under (e.g. ctfd.io, gmail.com, yahoo.com)", ) + team_creation = SelectField( + "Team Creation", + description="Control whether users can create their own teams (Teams mode only)", + choices=[("true", "Enabled"), ("false", "Disabled")], + default="true", + ) team_size = IntegerField( - widget=NumberInput(min=0), description="Amount of users per team" + widget=NumberInput(min=0), + description="Amount of users per team (Teams mode only)", ) verify_emails = SelectField( "Verify Emails", diff --git a/CTFd/teams.py b/CTFd/teams.py index 1d0a2e0d..1b99d6af 100644 --- a/CTFd/teams.py +++ b/CTFd/teams.py @@ -191,6 +191,12 @@ def new(): infos = get_infos() errors = get_errors() + if bool(get_config("team_creation", default=True)) is False: + abort( + 403, + description="Team creation is currently disabled. Please join an existing team.", + ) + user = get_current_user_attrs() if user.team_id: errors.append("You are already in a team. You cannot join another.") diff --git a/CTFd/themes/admin/templates/configs/accounts.html b/CTFd/themes/admin/templates/configs/accounts.html index dc518087..32ebdde5 100644 --- a/CTFd/themes/admin/templates/configs/accounts.html +++ b/CTFd/themes/admin/templates/configs/accounts.html @@ -2,7 +2,8 @@ {% set verify_emails = "true" if verify_emails == True else "false" %} {% set name_changes = "true" if name_changes == True else "false" %} - {% with form = Forms.config.AccountSettingsForm(verify_emails=verify_emails, name_changes=name_changes, team_disbanding=team_disbanding) %} + {% set team_creation = "true" if team_creation == True else "false" %} + {% with form = Forms.config.AccountSettingsForm(verify_emails=verify_emails, name_changes=name_changes, team_disbanding=team_disbanding, team_creation=team_creation) %}