Only call load_user_solves if authed (#769)

* Only call load_user_solves if authed
* Fix user.html page links
This commit is contained in:
Kevin Chung
2018-11-30 21:52:10 -05:00
committed by GitHub
parent 4233d683b8
commit 56178840fe
3 changed files with 20 additions and 15 deletions

View File

@@ -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);

View File

@@ -53,6 +53,9 @@
{% endblock %}
{% block scripts %}
<script>
var authed = {{ (id is defined) | tojson }};
</script>
<script src="{{ url_for('views.themes', theme=get_ctf_theme(), path='js/utils.js') }}"></script>
<script src="{{ url_for('views.themes', theme=get_ctf_theme(), path='js/multi-modal.js') }}"></script>
{% if admin or not errors %}

View File

@@ -74,19 +74,19 @@
<div class="text-center">Page
<br>
{% if curr_page != 1 %}
<a href="{{ url_for('admin.users_listing', page=curr_page - 1) }}">
<a href="{{ url_for('users.listing', page=curr_page - 1) }}">
&lt;&lt;&lt;
</a>
{% endif %}
{% for page in range(1, pages + 1) %}
{% if curr_page != page %}
<a href="{{ url_for('admin.users_listing', page=page) }}">{{ page }}</a>
<a href="{{ url_for('users.listing', page=page) }}">{{ page }}</a>
{% else %}
<b>{{ page }}</b>
{% endif %}
{% endfor %}
{% if curr_page != pages %}
<a href="{{ url_for('admin.users_listing', page=curr_page + 1) }}">
<a href="{{ url_for('users.listing', page=curr_page + 1) }}">
&gt;&gt;&gt;
</a>
{% endif %}