Skip to content

Commit

Permalink
Merge branch 'main' into refactor-fix-non-strict-and-non-explicit-rel…
Browse files Browse the repository at this point in the history
…ationships
  • Loading branch information
jaredgalanis authored Jun 27, 2024
2 parents c52502b + cd2ef74 commit d6bf20e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
9 changes: 6 additions & 3 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ export default class ApplicationAdapter extends JSONAPIAdapter {

namespace = ENV.passApi.namespace;

headers = {
withCredentials: true,
};
get headers() {
return {
withCredentials: true,
'X-XSRF-TOKEN': document.cookie.match(/XSRF-TOKEN\=([^;]*)/)['1'],
};
}

// Camel case instead of pluralize model types for our API
pathForType(type) {
Expand Down
4 changes: 4 additions & 0 deletions app/adapters/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default class FileAdapter extends ApplicationAdapter {
}
return fetch(url, {
method: 'DELETE',
credentials: 'same-origin',
headers: {
'X-XSRF-TOKEN': document.cookie.match(/XSRF-TOKEN\=([^;]*)/)['1'],
},
}).then((response) => {
if (!response.ok) {
throw new Error('Delete request to the file service failed');
Expand Down
7 changes: 6 additions & 1 deletion app/components/workflow-files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export default class WorkflowFiles extends Component {
@action
async uploadFile(FileUpload) {
try {
const response = await FileUpload.upload(ENV.fileServicePath);
const response = await FileUpload.upload(ENV.fileServicePath, {
withCredentials: true,
headers: {
'X-XSRF-TOKEN': document.cookie.match(/XSRF-TOKEN\=([^;]*)/)['1'],
},
});

const file = await response.json();

Expand Down
1 change: 1 addition & 0 deletions app/services/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class DoiService extends Service {
headers: {
Accept: 'application/json; charset=utf-8',
withCredentials: 'include',
'X-XSRF-TOKEN': document.cookie.match(/XSRF-TOKEN\=([^;]*)/)['1'],
},
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pass-ui",
"version": "1.7.0-SNAPSHOT",
"version": "1.8.0-SNAPSHOT",
"private": true,
"description": "The user interface for the eclipse-pass project",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ setupSinon();
setup(QUnit.assert);

start();

// Set a fake CSRF token
document.cookie = 'XSRF-TOKEN=moo';

0 comments on commit d6bf20e

Please sign in to comment.