Add teamId and teamName to base.html (#2106)

- Add `teamId` and `teamName` to the CTFd init object in `base.html` for easier integration with other JavaScript code
This commit is contained in:
Kevin Chung
2022-05-03 05:00:28 -04:00
committed by GitHub
parent 4369272c49
commit d2b2d7d880
3 changed files with 11 additions and 0 deletions

View File

@@ -50,6 +50,7 @@
- Create the `core-beta` theme and begin documenting the creation of themes using Vite
- Add `userName` and `userEmail` to the CTFd init object in `base.html` for easier integration with other JavaScript code
- Add `teamId` and `teamName` to the CTFd init object in `base.html` for easier integration with other JavaScript code
- Adds the `Assets` constant to access front end assets from Jinja templates
- Adds a `views.themes_beta` route to avoid the `.dev`/`.min` extension being added automatically to frontend asset urls

View File

@@ -20,6 +20,8 @@
'userId': {{ Session.id }},
'userName': "{{ User.name }}",
'userEmail': "{{ User.email }}",
'teamId': {{ Team.id | tojson }},
'teamName': "{{ Team.name }}",
'start': {{ Configs.start | tojson }},
'end': {{ Configs.end | tojson }},
'theme_settings': {{ Configs.theme_settings | tojson }}

View File

@@ -69,6 +69,10 @@ def test_hidden_teams_visibility():
r = client.get("/teams")
response = r.get_data(as_text=True)
# Only search in body content
body_start = response.find("<body>")
body_end = response.find("</body>")
response = response[body_start:body_end]
assert team_name not in response
r = client.get("/api/v1/teams")
@@ -79,6 +83,10 @@ def test_hidden_teams_visibility():
r = client.get("/scoreboard")
response = r.get_data(as_text=True)
# Only search in body content
body_start = response.find("<body>")
body_end = response.find("</body>")
response = response[body_start:body_end]
assert team_name not in response
r = client.get("/api/v1/scoreboard")