diff --git a/src/app/core/data/item-request-data.service.ts b/src/app/core/data/item-request-data.service.ts index ff6025f7ac8..b14921a66e8 100644 --- a/src/app/core/data/item-request-data.service.ts +++ b/src/app/core/data/item-request-data.service.ts @@ -50,15 +50,22 @@ export class ItemRequestDataService extends IdentifiableDataService * Request a copy of an item * @param itemRequest */ - requestACopy(itemRequest: ItemRequest): Observable> { + requestACopy(itemRequest: ItemRequest, captchaToken: string = null): Observable> { const requestId = this.requestService.generateRequestId(); const href$ = this.getItemRequestEndpoint(); + + const options: HttpOptions = Object.create({}); + let headers = new HttpHeaders(); + if (captchaToken) { + headers = headers.append('x-recaptcha-token', captchaToken); + } + options.headers = headers; href$.pipe( find((href: string) => hasValue(href)), map((href: string) => { - const request = new PostRequest(requestId, href, itemRequest); + const request = new PostRequest(requestId, href, itemRequest,options); this.requestService.send(request); }) ).subscribe(); diff --git a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts index 53c364389ba..d55fa64f812 100644 --- a/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts +++ b/src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts @@ -61,7 +61,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy { */ checkboxCheckedSubject$ = new BehaviorSubject(false); disableUntilChecked = true; - + captchaToken:string; captchaVersion(): Observable { this.cdRef.detectChanges(); return this.googleRecaptchaService.captchaVersion(); @@ -208,7 +208,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy { itemRequest.requestName = this.name.value; itemRequest.requestMessage = this.message.value; - this.itemRequestDataService.requestACopy(itemRequest).pipe( + this.itemRequestDataService.requestACopy(itemRequest,this.captchaToken).pipe( getFirstCompletedRemoteData() ).subscribe((rd) => { if (rd.hasSucceeded) { @@ -279,7 +279,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy { ).subscribe((token) => { if (isNotEmpty(token)) { // this.onSubmit(); - + this.captchaToken = token; this.registrationVerification = true; } else {