Skip to content

Commit 396015a

Browse files
committed
Add CSRF header to $.ajax calls
1 parent 101e9c6 commit 396015a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/dashboard/src/media/js/ingest/as_matcher.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ var ATKMatcherView = Backbone.View.extend({
119119
'file_uuid': uuid
120120
}),
121121
dataType: 'json',
122+
headers: {'X-CSRFToken': getCookie('csrftoken')},
122123
success: function(result) {
123124
// TODO: make the display of the "delete" button conditional on success
124125
}
@@ -140,6 +141,7 @@ var ATKMatcherView = Backbone.View.extend({
140141
'file_uuid': uuid,
141142
}),
142143
dataType: 'json',
144+
headers: {'X-CSRFToken': getCookie('csrftoken')},
143145
success: function(result) {
144146
// TODO: delete the pair from the UI, and reactivate the elements?
145147
// Or leave that to happen independent of the request?
@@ -596,6 +598,7 @@ var ATKMatcherView = Backbone.View.extend({
596598
context: this,
597599
type: 'POST',
598600
dataType: 'json',
601+
headers: {'X-CSRFToken': getCookie('csrftoken')},
599602
data: {pairs: self.pairCollection.toJSON()},
600603
success: function(result)
601604
{

src/dashboard/src/media/js/ingest/metadata_form.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var MetadataFormView = Backbone.View.extend({
5959
sip_uuid: this.sipUUID,
6060
source_paths: sourcePaths,
6161
},
62+
headers: {'X-CSRFToken': getCookie('csrftoken')},
6263
success: function(results) {
6364
if (results['error']) {
6465
alert(results['error'])

src/dashboard/src/media/js/repeating-ajax-data.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ var RepeatingDataRecordView = Backbone.View.extend({
9292
url: self.url,
9393
type: 'POST',
9494
data: data,
95+
headers: {'X-CSRFToken': getCookie('csrftoken')},
9596
success: function(result) {
9697
$input.hide();
9798
$input.fadeIn();
@@ -188,6 +189,7 @@ var RepeatingDataView = Backbone.View.extend({
188189
url: self.url,
189190
type: 'POST',
190191
data: field.getValues(),
192+
headers: {'X-CSRFToken': getCookie('csrftoken')},
191193
success: function(result) {
192194
$(self).attr('disabled', 'false');
193195
self.waitingForInput = false;
@@ -218,6 +220,7 @@ var RepeatingDataView = Backbone.View.extend({
218220
url: self.url + '/' + id,
219221
type: 'DELETE',
220222
data: {'id': id},
223+
headers: {'X-CSRFToken': getCookie('csrftoken')},
221224
success: function(result) {
222225
self.render();
223226
}

0 commit comments

Comments
 (0)