mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
* Don't require a team for viewing challenges if Challenge visibility is set to public * Closes #1831
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from flask import Blueprint, redirect, render_template, request, url_for
|
|
|
|
from CTFd.constants.config import ChallengeVisibilityTypes, Configs
|
|
from CTFd.utils.config import is_teams_mode
|
|
from CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started
|
|
from CTFd.utils.decorators import during_ctf_time_only, require_verified_emails
|
|
from CTFd.utils.decorators.visibility import check_challenge_visibility
|
|
from CTFd.utils.helpers import get_errors, get_infos
|
|
from CTFd.utils.user import authed, get_current_team
|
|
|
|
challenges = Blueprint("challenges", __name__)
|
|
|
|
|
|
@challenges.route("/challenges", methods=["GET"])
|
|
@during_ctf_time_only
|
|
@require_verified_emails
|
|
@check_challenge_visibility
|
|
def listing():
|
|
if (
|
|
Configs.challenge_visibility == ChallengeVisibilityTypes.PUBLIC
|
|
and authed() is False
|
|
):
|
|
pass
|
|
else:
|
|
if is_teams_mode() and get_current_team() is None:
|
|
return redirect(url_for("teams.private", next=request.full_path))
|
|
|
|
infos = get_infos()
|
|
errors = get_errors()
|
|
|
|
if ctf_started() is False:
|
|
errors.append(f"{Configs.ctf_name} has not started yet")
|
|
|
|
if ctf_paused() is True:
|
|
infos.append(f"{Configs.ctf_name} is paused")
|
|
|
|
if ctf_ended() is True:
|
|
infos.append(f"{Configs.ctf_name} has ended")
|
|
|
|
return render_template("challenges.html", infos=infos, errors=errors)
|