mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[DURACOM-312] set the X-On-Behalf-Of header with impersonatingID in FileUploader.
(cherry picked from commit 727bcdc2cb23ae7fcff1d9ddfa794f872f1d1b8c)
This commit is contained in:
@@ -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() },
|
||||
...(hasValue(this.uploadFilesOptions.impersonatingID)
|
||||
? [{ name: this.ON_BEHALF_HEADER, value: this.uploadFilesOptions.impersonatingID }]
|
||||
: [])
|
||||
];
|
||||
this.onBeforeUpload();
|
||||
this.isOverDocumentDropZone = observableOf(false);
|
||||
};
|
||||
|
Reference in New Issue
Block a user