mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-19 23:14:18 +01:00
Limit total number of teams (#1867)
* Adds support for a total teams limit
This commit is contained in:
@@ -197,6 +197,14 @@ def new():
|
||||
description="Team creation is currently disabled. Please join an existing team.",
|
||||
)
|
||||
|
||||
num_teams_limit = int(get_config("num_teams", default=0))
|
||||
num_teams = Teams.query.filter_by(banned=False, hidden=False).count()
|
||||
if num_teams_limit and num_teams >= num_teams_limit:
|
||||
abort(
|
||||
403,
|
||||
description=f"Reached the maximum number of teams ({num_teams_limit}). 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.")
|
||||
|
||||
Reference in New Issue
Block a user