mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Bug fix. Ensure we check for changed token in empty responses. Also ensure we send token before each upload (as it might change between uploads)
This commit is contained in:
@@ -114,8 +114,6 @@ export class UploaderComponent {
|
||||
autoUpload: this.uploadFilesOptions.autoUpload,
|
||||
method: this.uploadFilesOptions.method,
|
||||
queueLimit: this.uploadFilesOptions.maxFileNumber,
|
||||
// Ensure the current XSRF token is included in every upload request
|
||||
headers: [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }]
|
||||
});
|
||||
|
||||
if (isUndefined(this.enableDragOverDocument)) {
|
||||
@@ -140,6 +138,8 @@ export class UploaderComponent {
|
||||
if (item.url !== this.uploader.options.url) {
|
||||
item.url = this.uploader.options.url;
|
||||
}
|
||||
// Ensure the current XSRF token is included in every upload request (token may change between items uploaded)
|
||||
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
|
||||
this.onBeforeUpload();
|
||||
this.isOverDocumentDropZone = observableOf(false);
|
||||
|
||||
@@ -155,7 +155,6 @@ export class UploaderComponent {
|
||||
};
|
||||
}
|
||||
this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
|
||||
if (isNotEmpty(response)) {
|
||||
// Check for a changed XSRF token in response & save new token if found
|
||||
// NOTE: this is only necessary because ng2-file-upload doesn't use an Http service and therefore never
|
||||
// triggers our xsrf.interceptor.ts. See this bug: https://github.com/valor-software/ng2-file-upload/issues/950
|
||||
@@ -163,6 +162,8 @@ export class UploaderComponent {
|
||||
if (isNotEmpty(token)) {
|
||||
this.saveXsrfToken(token);
|
||||
}
|
||||
|
||||
if (isNotEmpty(response)) {
|
||||
const responsePath = JSON.parse(response);
|
||||
this.onCompleteItem.emit(responsePath);
|
||||
}
|
||||
|
Reference in New Issue
Block a user