From 4793d95338935686ef005c24ebb6606e1be7403b Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 7 Sep 2022 14:40:42 -0400 Subject: [PATCH] Emit more theme init data using tojson (#2182) * Emit more theme init data using tojson * Add `teamId` and `teamName` into admin `base.html` --- CTFd/themes/admin/templates/base.html | 14 ++++++++------ CTFd/themes/core/templates/base.html | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CTFd/themes/admin/templates/base.html b/CTFd/themes/admin/templates/base.html index ea457509..adb435ba 100644 --- a/CTFd/themes/admin/templates/base.html +++ b/CTFd/themes/admin/templates/base.html @@ -15,12 +15,14 @@ var init = { 'urlRoot': "{{ request.script_root }}", 'csrfNonce': "{{ Session.nonce }}", - 'userMode': "{{ get_config('user_mode') }}", - 'userId': {{ id if (id is defined) else 0 }}, - 'userName': "{{ User.name }}", - 'userEmail': "{{ User.email }}", - 'start': {{ get_config("start") | tojson }}, - 'end': {{ get_config("end") | tojson }}, + 'userMode': "{{ Configs.user_mode }}", + 'userId': {{ Session.id }}, + 'userName': {{ User.name | tojson }}, + 'userEmail': {{ User.email | tojson }}, + 'teamId': {{ Team.id | tojson }}, + 'teamName': {{ Team.name | tojson }}, + 'start': {{ Configs.start | tojson }}, + 'end': {{ Configs.end | tojson }} } {% block stylesheets %} {% endblock %} diff --git a/CTFd/themes/core/templates/base.html b/CTFd/themes/core/templates/base.html index 56236f2f..bb6b43c9 100644 --- a/CTFd/themes/core/templates/base.html +++ b/CTFd/themes/core/templates/base.html @@ -18,10 +18,10 @@ 'csrfNonce': "{{ Session.nonce }}", 'userMode': "{{ Configs.user_mode }}", 'userId': {{ Session.id }}, - 'userName': "{{ User.name }}", - 'userEmail': "{{ User.email }}", + 'userName': {{ User.name | tojson }}, + 'userEmail': {{ User.email | tojson }}, 'teamId': {{ Team.id | tojson }}, - 'teamName': "{{ Team.name }}", + 'teamName': {{ Team.name | tojson }}, 'start': {{ Configs.start | tojson }}, 'end': {{ Configs.end | tojson }}, 'theme_settings': {{ Configs.theme_settings | tojson }}