Commit ef4e566d authored by Michael Rose's avatar Michael Rose

js: add CSRF token to outgoing xhrs (since jquery ujs isnt doing it anymore?)

parent 4c19c48b
......@@ -11,7 +11,6 @@
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require rails-timeago
//= require bootstrap-sprockets
//= require chosen-jquery
......
......@@ -9,6 +9,7 @@
window.$ = window.jQuery = require("jquery");
require('chosen-jquery/lib/chosen.jquery');
import {} from 'jquery-ujs'
window.init = function() {
......@@ -263,6 +264,11 @@ window.init = function() {
};
$(function() {
$(document).ajaxSend(function(e, xhr, options) {
var token = $('meta[name="csrf-token"]').attr('content');
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
});
$('.report-broken').click(function(e) {
e.stopImmediatePropagation();
const story_id = $(this).data('story-id');
......
......@@ -8,6 +8,7 @@
"coffeescript": "^2.2.2",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"jquery-ujs": "^1.2.2",
"less": "^2.3.1",
"less-loader": "^4.0.6",
"popper.js": "^1.12.9",
......
......@@ -3051,7 +3051,13 @@ jquery-mousewheel@~3.1.13:
version "3.1.13"
resolved "https://registry.yarnpkg.com/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz#06f0335f16e353a695e7206bf50503cb523a6ee5"
jquery@^3.3.1:
jquery-ujs@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/jquery-ujs/-/jquery-ujs-1.2.2.tgz#6a8ef1020e6b6dda385b90a4bddc128c21c56397"
dependencies:
jquery ">=1.8.0"
jquery@>=1.8.0, jquery@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment