Skip to content

Commit

Permalink
Addea TOken TO header
Browse files Browse the repository at this point in the history
  • Loading branch information
GauravD2t committed Dec 18, 2023
1 parent 2e5ad2d commit 262975b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/app/core/data/item-request-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,22 @@ export class ItemRequestDataService extends IdentifiableDataService<ItemRequest>
* Request a copy of an item
* @param itemRequest
*/
requestACopy(itemRequest: ItemRequest): Observable<RemoteData<ItemRequest>> {
requestACopy(itemRequest: ItemRequest, captchaToken: string = null): Observable<RemoteData<ItemRequest>> {
const requestId = this.requestService.generateRequestId();

const href$ = this.getItemRequestEndpoint();

Check failure on line 57 in src/app/core/data/item-request-data.service.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Trailing spaces not allowed

Check failure on line 57 in src/app/core/data/item-request-data.service.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Trailing spaces not allowed
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
*/
checkboxCheckedSubject$ = new BehaviorSubject<boolean>(false);
disableUntilChecked = true;

captchaToken:string;

Check failure on line 64 in src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Expected a space after the ':'

Check failure on line 64 in src/app/item-page/bitstreams/request-a-copy/bitstream-request-a-copy-page.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Expected a space after the ':'
captchaVersion(): Observable<string> {
this.cdRef.detectChanges();
return this.googleRecaptchaService.captchaVersion();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -279,7 +279,7 @@ export class BitstreamRequestACopyPageComponent implements OnInit, OnDestroy {
).subscribe((token) => {
if (isNotEmpty(token)) {
// this.onSubmit();

this.captchaToken = token;
this.registrationVerification = true;

} else {
Expand Down

0 comments on commit 262975b

Please sign in to comment.