Skip to content

Commit aaa4b91

Browse files
authored
Merge pull request #4307 from DSpace/backport-4288-to-dspace-7_x
[Port dspace-7_x] Bitstream upload failure during the workflow editing process when impersonating an editor
2 parents f9f3d18 + 926abe6 commit aaa4b91

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/app/shared/upload/uploader/uploader-options.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export class UploaderOptions {
2222
*/
2323
maxFileNumber: number;
2424

25+
/**
26+
* Impersonating user uuid
27+
*/
28+
impersonatingID: string;
29+
2530
/**
2631
* The request method to use for the file upload request
2732
*/

src/app/shared/upload/uploader/uploader.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import { DragService } from '../../../core/drag.service';
2323

2424
export class UploaderComponent {
2525

26+
/**
27+
* Header key to impersonate a user
28+
*/
29+
private readonly ON_BEHALF_HEADER = 'X-On-Behalf-Of';
30+
2631
/**
2732
* The message to show when drag files on the drop zone
2833
*/
@@ -139,7 +144,13 @@ export class UploaderComponent {
139144
item.url = this.uploader.options.url;
140145
}
141146
// Ensure the current XSRF token is included in every upload request (token may change between items uploaded)
142-
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
147+
// Ensure the behalf header is set if impersonating
148+
this.uploader.options.headers = [
149+
{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() },
150+
];
151+
if (hasValue(this.uploadFilesOptions.impersonatingID)) {
152+
this.uploader.options.headers.push({ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID });
153+
}
143154
this.onBeforeUpload();
144155
this.isOverDocumentDropZone = observableOf(false);
145156
};

src/app/submission/form/submission-form.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
173173
distinctUntilChanged())
174174
.subscribe((endpointURL) => {
175175
this.uploadFilesOptions.authToken = this.authService.buildAuthHeader();
176+
this.uploadFilesOptions.impersonatingID = this.authService.getImpersonateID();
176177
this.uploadFilesOptions.url = endpointURL.concat(`/${this.submissionId}`);
177178
this.definitionId = this.submissionDefinition.name;
178179
this.submissionService.dispatchInit(

0 commit comments

Comments
 (0)