diff --git a/src/core/infra/repositories/ApiRepository.ts b/src/core/infra/repositories/ApiRepository.ts index db841d7c..84edfce2 100644 --- a/src/core/infra/repositories/ApiRepository.ts +++ b/src/core/infra/repositories/ApiRepository.ts @@ -10,9 +10,9 @@ import { WriteError } from '../../domain/repositories/WriteError'; For 2.0.0, we must also support API key auth to be backwards compatible and support use cases other than SPA MVP. */ export abstract class ApiRepository { - public async doGet(apiEndpoint: string): Promise { + public async doGet(apiEndpoint: string, withCredentials: boolean = false): Promise { return await axios - .get(this.buildRequestUrl(apiEndpoint), { withCredentials: true }) + .get(this.buildRequestUrl(apiEndpoint), { withCredentials: withCredentials }) .then((response) => response) .catch((error) => { throw new ReadError( diff --git a/src/users/infra/repositories/UsersRepository.ts b/src/users/infra/repositories/UsersRepository.ts index cbf54543..a9d5856d 100644 --- a/src/users/infra/repositories/UsersRepository.ts +++ b/src/users/infra/repositories/UsersRepository.ts @@ -5,7 +5,7 @@ import { AxiosResponse } from 'axios'; export class UsersRepository extends ApiRepository implements IUsersRepository { public async getCurrentAuthenticatedUser(): Promise { - return this.doGet('/users/:me') + return this.doGet('/users/:me', true) .then((response) => this.getAuthenticatedUserFromResponse(response)) .catch((error) => { throw error; diff --git a/test/unit/info/DataverseInfoRepository.test.ts b/test/unit/info/DataverseInfoRepository.test.ts index 857c134c..e77160f3 100644 --- a/test/unit/info/DataverseInfoRepository.test.ts +++ b/test/unit/info/DataverseInfoRepository.test.ts @@ -32,7 +32,7 @@ describe('getDataverseVersion', () => { const actual = await sut.getDataverseVersion(); - assert.calledWithExactly(axiosGetStub, `${testApiUrl}/info/version`, { withCredentials: true }); + assert.calledWithExactly(axiosGetStub, `${testApiUrl}/info/version`, { withCredentials: false }); assert.match(actual.number, testVersionNumber); assert.match(actual.build, testVersionBuild); }); @@ -49,7 +49,7 @@ describe('getDataverseVersion', () => { let error: ReadError = undefined; await sut.getDataverseVersion().catch((e) => (error = e)); - assert.calledWithExactly(axiosGetStub, `${testApiUrl}/info/version`, { withCredentials: true }); + assert.calledWithExactly(axiosGetStub, `${testApiUrl}/info/version`, { withCredentials: false }); expect(error).to.be.instanceOf(Error); }); });