From 3b5ef3b0a88247eeafeee878de528aad71f9fd4b Mon Sep 17 00:00:00 2001 From: maxbr Date: Fri, 19 Aug 2016 17:10:31 +0200 Subject: Split the dashboard into different apps, add tests JIRA: RELENG-12 Signed-off-by: maxbr --- tools/pharos-dashboard/dashboard/static/js/csrf.js | 34 ---------------------- 1 file changed, 34 deletions(-) delete mode 100644 tools/pharos-dashboard/dashboard/static/js/csrf.js (limited to 'tools/pharos-dashboard/dashboard/static/js/csrf.js') diff --git a/tools/pharos-dashboard/dashboard/static/js/csrf.js b/tools/pharos-dashboard/dashboard/static/js/csrf.js deleted file mode 100644 index 12429b38..00000000 --- a/tools/pharos-dashboard/dashboard/static/js/csrf.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * use django csrf token in ajax requests - * source: https://docs.djangoproject.com/en/1.8/ref/csrf/#ajax - */ -// using jQuery -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'); - -function csrfSafeMethod(method) { - // these HTTP methods do not require CSRF protection - return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); -} - -$.ajaxSetup({ - beforeSend: function (xhr, settings) { - if (!csrfSafeMethod(settings.type) && !this.crossDomain) { - xhr.setRequestHeader("X-CSRFToken", csrftoken); - } - } -}); \ No newline at end of file -- cgit 1.2.3-korg