Skip to content

Commit dec05e5

Browse files
authored
Merge pull request #4288 from 4Science/task/main/DURACOM-312
Bitstream upload failure during the workflow editing process when impersonating an editor
2 parents c2af23b + c68e5a1 commit dec05e5

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
@@ -47,6 +47,11 @@ import { UploaderProperties } from './uploader-properties.model';
4747
})
4848
export class UploaderComponent implements OnInit, AfterViewInit {
4949

50+
/**
51+
* Header key to impersonate a user
52+
*/
53+
private readonly ON_BEHALF_HEADER = 'X-On-Behalf-Of';
54+
5055
/**
5156
* The message to show when drag files on the drop zone
5257
*/
@@ -162,7 +167,13 @@ export class UploaderComponent implements OnInit, AfterViewInit {
162167
item.url = this.uploader.options.url;
163168
}
164169
// Ensure the current XSRF token is included in every upload request (token may change between items uploaded)
165-
this.uploader.options.headers = [{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() }];
170+
// Ensure the behalf header is set if impersonating
171+
this.uploader.options.headers = [
172+
{ name: XSRF_REQUEST_HEADER, value: this.tokenExtractor.getToken() },
173+
];
174+
if (hasValue(this.uploadFilesOptions.impersonatingID)) {
175+
this.uploader.options.headers.push({ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID });
176+
}
166177
this.onBeforeUpload();
167178
this.isOverDocumentDropZone = observableOf(false);
168179
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
211211
distinctUntilChanged())
212212
.subscribe((endpointURL) => {
213213
this.uploadFilesOptions.authToken = this.authService.buildAuthHeader();
214+
this.uploadFilesOptions.impersonatingID = this.authService.getImpersonateID();
214215
this.uploadFilesOptions.url = endpointURL.concat(`/${this.submissionId}`);
215216
this.definitionId = this.submissionDefinition.name;
216217
this.submissionService.dispatchInit(

0 commit comments

Comments
 (0)