From b798898076e4d757426056859f5fb963d6947368 Mon Sep 17 00:00:00 2001 From: Koen Bolhuis Date: Tue, 9 Oct 2018 22:12:41 +0200 Subject: [PATCH] Implement easier way to retrieve CSRF token --- .../templates/postings/frontend/entity.html | 2 +- frontpage/rateables/js/voting.js | 17 +---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/backend/postings/templates/postings/frontend/entity.html b/backend/postings/templates/postings/frontend/entity.html index 1db3136..7b8d11b 100644 --- a/backend/postings/templates/postings/frontend/entity.html +++ b/backend/postings/templates/postings/frontend/entity.html @@ -162,7 +162,7 @@ - {% csrf_token %} +
{% csrf_token %}
diff --git a/frontpage/rateables/js/voting.js b/frontpage/rateables/js/voting.js index fddc9bd..55247aa 100644 --- a/frontpage/rateables/js/voting.js +++ b/frontpage/rateables/js/voting.js @@ -1,20 +1,5 @@ $(function() { - function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; - } - var csrftoken = getCookie('csrftoken'); + var csrftoken = $("#csrf-token input").val(); $(".vote-up").click(function() { var reviewId = $(this).attr("data-review-id");