Added info for challenges page Admins Only mode (#2138)

* Added info stating "Challenges are set to Admins Only mode" for admins in relevant case so they don't forget as per issue #2137
* Closes #2137

Co-authored-by: Kevin Chung <kchung@ctfd.io>
This commit is contained in:
Joel Butler
2022-06-19 19:33:29 -04:00
committed by GitHub
parent f1cc09767f
commit a1d9c12a91
2 changed files with 10 additions and 1 deletions

View File

@@ -33,6 +33,9 @@ def listing():
infos = get_infos() infos = get_infos()
errors = get_errors() errors = get_errors()
if Configs.challenge_visibility == ChallengeVisibilityTypes.ADMINS:
infos.append("Challenge Visibility is set to Admins Only")
if ctf_started() is False: if ctf_started() is False:
errors.append(f"{Configs.ctf_name} has not started yet") errors.append(f"{Configs.ctf_name} has not started yet")

View File

@@ -73,7 +73,13 @@ def check_challenge_visibility(f):
return f(*args, **kwargs) return f(*args, **kwargs)
else: else:
if authed(): if authed():
if request.content_type == "application/json":
abort(403) abort(403)
else:
abort(
403,
description="Challenge Visibility is set to Admins Only",
)
else: else:
return redirect(url_for("auth.login", next=request.full_path)) return redirect(url_for("auth.login", next=request.full_path))