prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Don't require teams for viewing challenges if challenges are public
  Looks like if challenges are set to be public but teams are required then challenges can't be seen. This requirement needs to be relaxed a bit. 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `CTFd/challenges.py`
  Content:
  ```
  1 from flask import Blueprint, render_template
  2 
  3 from CTFd.utils import config
  4 from CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started
  5 from CTFd.utils.decorators import (
  6     during_ctf_time_only,
  7     require_team,
  8     require_verified_emails,
  9 )
  10 from CTFd.utils.decorators.visibility import check_challenge_visibility
  11 from CTFd.utils.helpers import get_errors, get_infos
  12 
  13 challenges = Blueprint("challenges", __name__)
  14 
  15 
  16 @challenges.route("/challenges", methods=["GET"])
  17 @during_ctf_time_only
  18 @require_verified_emails
  19 @check_challenge_visibility
  20 @require_team
  21 def listing():
  22     infos = get_infos()
  23     errors = get_errors()
  24 
  25     if ctf_started() is False:
  26         errors.append(f"{config.ctf_name()} has not started yet")
  27 
  28     if ctf_paused() is True:
  29         infos.append(f"{config.ctf_name()} is paused")
  30 
  31     if ctf_ended() is True:
  32         infos.append(f"{config.ctf_name()} has ended")
  33 
  34     return render_template("challenges.html", infos=infos, errors=errors)
  35
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/CTFd/challenges.py b/CTFd/challenges.py
  --- a/CTFd/challenges.py
  +++ b/CTFd/challenges.py
  @@ -1,14 +1,12 @@
  -from flask import Blueprint, render_template
  +from flask import Blueprint, redirect, render_template, request, url_for
   
  -from CTFd.utils import config
  +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_team,
  -    require_verified_emails,
  -)
  +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__)
   
  @@ -17,18 +15,26 @@
   @during_ctf_time_only
   @require_verified_emails
   @check_challenge_visibility
  -@require_team
   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"{config.ctf_name()} has not started yet")
  +        errors.append(f"{Configs.ctf_name} has not started yet")
   
       if ctf_paused() is True:
  -        infos.append(f"{config.ctf_name()} is paused")
  +        infos.append(f"{Configs.ctf_name} is paused")
   
       if ctf_ended() is True:
  -        infos.append(f"{config.ctf_name()} has ended")
  +        infos.append(f"{Configs.ctf_name} has ended")
   
       return render_template("challenges.html", infos=infos, errors=errors)
  
verification_info: {"golden_diff": "diff --git a/CTFd/challenges.py b/CTFd/challenges.py\n--- a/CTFd/challenges.py\n+++ b/CTFd/challenges.py\n@@ -1,14 +1,12 @@\n-from flask import Blueprint, render_template\n+from flask import Blueprint, redirect, render_template, request, url_for\n \n-from CTFd.utils import config\n+from CTFd.constants.config import ChallengeVisibilityTypes, Configs\n+from CTFd.utils.config import is_teams_mode\n from CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started\n-from CTFd.utils.decorators import (\n-    during_ctf_time_only,\n-    require_team,\n-    require_verified_emails,\n-)\n+from CTFd.utils.decorators import during_ctf_time_only, require_verified_emails\n from CTFd.utils.decorators.visibility import check_challenge_visibility\n from CTFd.utils.helpers import get_errors, get_infos\n+from CTFd.utils.user import authed, get_current_team\n \n challenges = Blueprint(\"challenges\", __name__)\n \n@@ -17,18 +15,26 @@\n @during_ctf_time_only\n @require_verified_emails\n @check_challenge_visibility\n-@require_team\n def listing():\n+    if (\n+        Configs.challenge_visibility == ChallengeVisibilityTypes.PUBLIC\n+        and authed() is False\n+    ):\n+        pass\n+    else:\n+        if is_teams_mode() and get_current_team() is None:\n+            return redirect(url_for(\"teams.private\", next=request.full_path))\n+\n     infos = get_infos()\n     errors = get_errors()\n \n     if ctf_started() is False:\n-        errors.append(f\"{config.ctf_name()} has not started yet\")\n+        errors.append(f\"{Configs.ctf_name} has not started yet\")\n \n     if ctf_paused() is True:\n-        infos.append(f\"{config.ctf_name()} is paused\")\n+        infos.append(f\"{Configs.ctf_name} is paused\")\n \n     if ctf_ended() is True:\n-        infos.append(f\"{config.ctf_name()} has ended\")\n+        infos.append(f\"{Configs.ctf_name} has ended\")\n \n     return render_template(\"challenges.html\", infos=infos, errors=errors)\n", "issue": "Don't require teams for viewing challenges if challenges are public\nLooks like if challenges are set to be public but teams are required then challenges can't be seen. This requirement needs to be relaxed a bit. \n", "before_files": [{"content": "from flask import Blueprint, render_template\n\nfrom CTFd.utils import config\nfrom CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started\nfrom CTFd.utils.decorators import (\n    during_ctf_time_only,\n    require_team,\n    require_verified_emails,\n)\nfrom CTFd.utils.decorators.visibility import check_challenge_visibility\nfrom CTFd.utils.helpers import get_errors, get_infos\n\nchallenges = Blueprint(\"challenges\", __name__)\n\n\n@challenges.route(\"/challenges\", methods=[\"GET\"])\n@during_ctf_time_only\n@require_verified_emails\n@check_challenge_visibility\n@require_team\ndef listing():\n    infos = get_infos()\n    errors = get_errors()\n\n    if ctf_started() is False:\n        errors.append(f\"{config.ctf_name()} has not started yet\")\n\n    if ctf_paused() is True:\n        infos.append(f\"{config.ctf_name()} is paused\")\n\n    if ctf_ended() is True:\n        infos.append(f\"{config.ctf_name()} has ended\")\n\n    return render_template(\"challenges.html\", infos=infos, errors=errors)\n", "path": "CTFd/challenges.py"}], "after_files": [{"content": "from flask import Blueprint, redirect, render_template, request, url_for\n\nfrom CTFd.constants.config import ChallengeVisibilityTypes, Configs\nfrom CTFd.utils.config import is_teams_mode\nfrom CTFd.utils.dates import ctf_ended, ctf_paused, ctf_started\nfrom CTFd.utils.decorators import during_ctf_time_only, require_verified_emails\nfrom CTFd.utils.decorators.visibility import check_challenge_visibility\nfrom CTFd.utils.helpers import get_errors, get_infos\nfrom CTFd.utils.user import authed, get_current_team\n\nchallenges = Blueprint(\"challenges\", __name__)\n\n\n@challenges.route(\"/challenges\", methods=[\"GET\"])\n@during_ctf_time_only\n@require_verified_emails\n@check_challenge_visibility\ndef listing():\n    if (\n        Configs.challenge_visibility == ChallengeVisibilityTypes.PUBLIC\n        and authed() is False\n    ):\n        pass\n    else:\n        if is_teams_mode() and get_current_team() is None:\n            return redirect(url_for(\"teams.private\", next=request.full_path))\n\n    infos = get_infos()\n    errors = get_errors()\n\n    if ctf_started() is False:\n        errors.append(f\"{Configs.ctf_name} has not started yet\")\n\n    if ctf_paused() is True:\n        infos.append(f\"{Configs.ctf_name} is paused\")\n\n    if ctf_ended() is True:\n        infos.append(f\"{Configs.ctf_name} has ended\")\n\n    return render_template(\"challenges.html\", infos=infos, errors=errors)\n", "path": "CTFd/challenges.py"}]}