From 56178840fecbdd9e8a475c76489659537c2b6468 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Fri, 30 Nov 2018 21:52:10 -0500 Subject: [PATCH] Only call load_user_solves if authed (#769) * Only call load_user_solves if authed * Fix user.html page links --- CTFd/themes/core/static/js/challenges.js | 26 +++++++++++---------- CTFd/themes/core/templates/challenges.html | 3 +++ CTFd/themes/core/templates/users/users.html | 6 ++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CTFd/themes/core/static/js/challenges.js b/CTFd/themes/core/static/js/challenges.js index bb673984..ad39a326 100644 --- a/CTFd/themes/core/static/js/challenges.js +++ b/CTFd/themes/core/static/js/challenges.js @@ -190,18 +190,22 @@ function marksolves(cb) { } function load_user_solves(cb) { - $.get(script_root + '/api/v1/'+ user_mode +'/me/solves', function (response) { - var solves = response.data; + if (authed) { + $.get(script_root + '/api/v1/' + user_mode + '/me/solves', function (response) { + var solves = response.data; - for (var i = solves.length - 1; i >= 0; i--) { - var chal_id = solves[i].challenge_id; - user_solves.push(chal_id); + for (var i = solves.length - 1; i >= 0; i--) { + var chal_id = solves[i].challenge_id; + user_solves.push(chal_id); - } - if (cb) { - cb(); - } - }); + } + if (cb) { + cb(); + } + }); + } else { + cb(); + } } function getsolves(id) { @@ -276,8 +280,6 @@ function loadchals(cb) { $("#" + catid + "-row").find(".category-challenges > .challenges-row").append(chalwrap); } - // marksolves(); - $('.challenge-button').click(function (e) { loadchal(this.value); getsolves(this.value); diff --git a/CTFd/themes/core/templates/challenges.html b/CTFd/themes/core/templates/challenges.html index 8ed7f264..6d1a9bf5 100644 --- a/CTFd/themes/core/templates/challenges.html +++ b/CTFd/themes/core/templates/challenges.html @@ -53,6 +53,9 @@ {% endblock %} {% block scripts %} + {% if admin or not errors %} diff --git a/CTFd/themes/core/templates/users/users.html b/CTFd/themes/core/templates/users/users.html index ef6cd513..dc1f298f 100644 --- a/CTFd/themes/core/templates/users/users.html +++ b/CTFd/themes/core/templates/users/users.html @@ -74,19 +74,19 @@
Page
{% if curr_page != 1 %} - + <<< {% endif %} {% for page in range(1, pages + 1) %} {% if curr_page != page %} - {{ page }} + {{ page }} {% else %} {{ page }} {% endif %} {% endfor %} {% if curr_page != pages %} - + >>> {% endif %}