Skip to content

Commit 6fdb6d2

Browse files
[DSC-1864] Uncomment xsrf token validator
1 parent e5d68b1 commit 6fdb6d2

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/app/core/data/request.effects.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Injectable, Injector } from '@angular/core';
22

33
import { Actions, createEffect, ofType } from '@ngrx/effects';
4-
import { catchError, filter, map, mergeMap, take } from 'rxjs/operators';
4+
import { catchError, filter, map, mergeMap, take, withLatestFrom } from 'rxjs/operators';
55

66
import { hasValue, isNotEmpty } from '../../shared/empty.util';
77
import { StoreActionTypes } from '../../store.actions';
88
import { getClassForType } from '../cache/builders/build-decorators';
99
import { RawRestResponse } from '../dspace-rest/raw-rest-response.model';
1010
import { DspaceRestService } from '../dspace-rest/dspace-rest.service';
1111
import { DSpaceSerializer } from '../dspace-rest/dspace.serializer';
12-
//import { XSRFService } from '../xsrf/xsrf.service';
12+
import { XSRFService } from '../xsrf/xsrf.service';
1313
import {
1414
RequestActionTypes,
1515
RequestErrorAction,
@@ -22,25 +22,25 @@ import { ParsedResponse } from '../cache/response.models';
2222
import { RequestError } from './request-error.model';
2323
import { RestRequestWithResponseParser } from './rest-request-with-response-parser.model';
2424
import { RequestEntry } from './request-entry.model';
25+
import { RestRequestMethod } from './rest-request-method';
2526

2627
@Injectable()
2728
export class RequestEffects {
2829

29-
execute = createEffect(() => this.actions$.pipe(
30+
execute = createEffect(() => this.actions$.pipe(
3031
ofType(RequestActionTypes.EXECUTE),
3132
mergeMap((action: RequestExecuteAction) => {
3233
return this.requestService.getByUUID(action.payload).pipe(
3334
take(1)
3435
);
3536
}),
3637
filter((entry: RequestEntry) => hasValue(entry)),
37-
map((entry: RequestEntry) => entry.request),
38-
//TODO: test once rest part is aligned
39-
//withLatestFrom(this.xsrfService.tokenInitialized$),
38+
// TODO: test once rest part is aligned
39+
withLatestFrom(this.xsrfService.tokenInitialized$),
4040
// If it's a GET request, or we have an XSRF token, dispatch it immediately
4141
// Otherwise wait for the XSRF token first
42-
//filter(([entry, tokenInitialized]: [RequestEntry, boolean]) => entry.request.method === RestRequestMethod.GET || tokenInitialized === true),
43-
// map(([entry, tokenInitialized]: [RequestEntry, boolean]) => entry.request),
42+
filter(([entry, tokenInitialized]) => entry?.request?.method === RestRequestMethod.GET || tokenInitialized === true),
43+
map(([entry,]) => entry.request),
4444
mergeMap((request: RestRequestWithResponseParser) => {
4545
let body = request.body;
4646
if (isNotEmpty(request.body) && !request.isMultipart) {
@@ -81,7 +81,7 @@ export class RequestEffects {
8181
private restApi: DspaceRestService,
8282
private injector: Injector,
8383
protected requestService: RequestService,
84-
//protected xsrfService: XSRFService,
84+
protected xsrfService: XSRFService,
8585
) { }
8686

8787
}

0 commit comments

Comments
 (0)