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,6 +190,7 @@ function marksolves(cb) {
} }
function load_user_solves(cb) { function load_user_solves(cb) {
if (authed) {
$.get(script_root + '/api/v1/' + user_mode + '/me/solves', function (response) { $.get(script_root + '/api/v1/' + user_mode + '/me/solves', function (response) {
var solves = response.data; var solves = response.data;
@@ -202,6 +203,9 @@ function load_user_solves(cb) {
cb(); cb();
} }
}); });
} else {
cb();
}
} }
function getsolves(id) { function getsolves(id) {
@@ -276,8 +280,6 @@ function loadchals(cb) {
$("#" + catid + "-row").find(".category-challenges > .challenges-row").append(chalwrap); $("#" + catid + "-row").find(".category-challenges > .challenges-row").append(chalwrap);
} }
// marksolves();
$('.challenge-button').click(function (e) { $('.challenge-button').click(function (e) {
loadchal(this.value); loadchal(this.value);
getsolves(this.value); getsolves(this.value);

View File

@@ -53,6 +53,9 @@
{% endblock %} {% endblock %}
{% block scripts %} {% 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/utils.js') }}"></script>
<script src="{{ url_for('views.themes', theme=get_ctf_theme(), path='js/multi-modal.js') }}"></script> <script src="{{ url_for('views.themes', theme=get_ctf_theme(), path='js/multi-modal.js') }}"></script>
{% if admin or not errors %} {% if admin or not errors %}

View File

@@ -74,19 +74,19 @@
<div class="text-center">Page <div class="text-center">Page
<br> <br>
{% if curr_page != 1 %} {% 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; &lt;&lt;&lt;
</a> </a>
{% endif %} {% endif %}
{% for page in range(1, pages + 1) %} {% for page in range(1, pages + 1) %}
{% if curr_page != page %} {% 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 %} {% else %}
<b>{{ page }}</b> <b>{{ page }}</b>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if curr_page != pages %} {% 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; &gt;&gt;&gt;
</a> </a>
{% endif %} {% endif %}