Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Jan 17, 2020
1 parent 6636f1d commit 38b372b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('response', () => {
http.intercept(interceptor);
fetchMock.mock('*', 200);

await http.fetch('/foo-api', { asSystemApi: true });
await http.fetch('/foo-api', { asSystemRequest: true });

expect(sessionTimeoutMock.extend).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('responseError', () => {
http.intercept(interceptor);
fetchMock.mock('*', 401);

await expect(http.fetch('/foo-api', { asSystemApi: true })).rejects.toMatchInlineSnapshot(
await expect(http.fetch('/foo-api', { asSystemRequest: true })).rejects.toMatchInlineSnapshot(
`[Error: Unauthorized]`
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { HttpInterceptor, HttpErrorResponse, HttpResponse, IAnonymousPaths } from 'src/core/public';
import {
HttpInterceptor,
HttpInterceptorResponseError,
HttpResponse,
IAnonymousPaths,
} from 'src/core/public';

import { ISessionTimeout } from './session_timeout';

Expand All @@ -16,19 +21,19 @@ export class SessionTimeoutHttpInterceptor implements HttpInterceptor {
return;
}

if (httpResponse.fetchOptions.asSystemApi) {
if (httpResponse.fetchOptions.asSystemRequest) {
return;
}

this.sessionTimeout.extend(httpResponse.request.url);
}

responseError(httpErrorResponse: HttpErrorResponse) {
responseError(httpErrorResponse: HttpInterceptorResponseError) {
if (this.anonymousPaths.isAnonymous(window.location.pathname)) {
return;
}

if (httpErrorResponse.fetchOptions.asSystemApi) {
if (httpErrorResponse.fetchOptions.asSystemRequest) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {
HttpInterceptor,
HttpErrorResponse,
HttpInterceptorResponseError,
IHttpInterceptController,
IAnonymousPaths,
} from 'src/core/public';
Expand All @@ -16,7 +16,10 @@ import { SessionExpired } from './session_expired';
export class UnauthorizedResponseHttpInterceptor implements HttpInterceptor {
constructor(private sessionExpired: SessionExpired, private anonymousPaths: IAnonymousPaths) {}

responseError(httpErrorResponse: HttpErrorResponse, controller: IHttpInterceptController) {
responseError(
httpErrorResponse: HttpInterceptorResponseError,
controller: IHttpInterceptController
) {
if (this.anonymousPaths.isAnonymous(window.location.pathname)) {
return;
}
Expand Down

0 comments on commit 38b372b

Please sign in to comment.