mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #4308 from DSpace/backport-4288-to-dspace-8_x
[Port dspace-8_x] Bitstream upload failure during the workflow editing process when impersonating an editor
This commit is contained in:
@@ -22,6 +22,11 @@ export class UploaderOptions {
|
||||
*/
|
||||
maxFileNumber: number;
|
||||
|
||||
/**
|
||||
* Impersonating user uuid
|
||||
*/
|
||||
impersonatingID: string;
|
||||
|
||||
/**
|
||||
* The request method to use for the file upload request
|
||||
*/
|
||||
|
@@ -47,6 +47,11 @@ import { UploaderProperties } from './uploader-properties.model';
|
||||
})
|
||||
export class UploaderComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/**
|
||||
* Header key to impersonate a user
|
||||
*/
|
||||
private readonly ON_BEHALF_HEADER = 'X-On-Behalf-Of';
|
||||
|
||||
/**
|
||||
* The message to show when drag files on the drop zone
|
||||
*/
|
||||
@@ -162,7 +167,13 @@ export class UploaderComponent implements OnInit, AfterViewInit {
|
||||
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() }];
|
||||
// Ensure the behalf header is set if impersonating
|
||||
this.uploader.options.headers = [
|
||||
{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() },
|
||||
];
|
||||
if (hasValue(this.uploadFilesOptions.impersonatingID)) {
|
||||
this.uploader.options.headers.push({ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID });
|
||||
}
|
||||
this.onBeforeUpload();
|
||||
this.isOverDocumentDropZone = observableOf(false);
|
||||
};
|
||||
|
@@ -209,6 +209,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
|
||||
distinctUntilChanged())
|
||||
.subscribe((endpointURL) => {
|
||||
this.uploadFilesOptions.authToken = this.authService.buildAuthHeader();
|
||||
this.uploadFilesOptions.impersonatingID = this.authService.getImpersonateID();
|
||||
this.uploadFilesOptions.url = endpointURL.concat(`/${this.submissionId}`);
|
||||
this.definitionId = this.submissionDefinition.name;
|
||||
this.submissionService.dispatchInit(
|
||||
|
Reference in New Issue
Block a user