diff --git a/src/identity-utils.ts b/src/identity-utils.ts index d363db774..88d7ef82f 100644 --- a/src/identity-utils.ts +++ b/src/identity-utils.ts @@ -76,7 +76,13 @@ export const cacheIdentityRequest = ( const cacheKey = concatenateIdentities(method, identities); const hashedKey = generateHash(cacheKey); - cache[hashedKey] = { responseText: xhr.responseText, status: xhr.status, expireTimestamp}; + const { mpid, is_logged_in } = JSON.parse(xhr.responseText); + const cachedResponseText = { + mpid, + is_logged_in, + }; + + cache[hashedKey] = { responseText: JSON.stringify(cachedResponseText), status: xhr.status, expireTimestamp}; idCache.store(cache); }; diff --git a/test/src/tests-identity-utils.ts b/test/src/tests-identity-utils.ts index fd5ad7168..1d0fbdebf 100644 --- a/test/src/tests-identity-utils.ts +++ b/test/src/tests-identity-utils.ts @@ -172,8 +172,10 @@ describe('identity-utils', () => { expect(cachedIdentityCall.status).to.equal(200); expect(cachedIdentityCall.expireTimestamp).to.equal(currentTime); - const responseText = JSON.parse(cachedIdentityCall.responseText); - expect(responseText).to.deep.equal(identifyResponse); + const cachedResponseText = JSON.parse(cachedIdentityCall.responseText); + + const expectedResponseText = {mpid: testMPID, is_logged_in: false}; + expect(cachedResponseText).to.deep.equal(expectedResponseText); }); it('should save a login request to local storage', () => { @@ -184,7 +186,6 @@ describe('identity-utils', () => { ...identifyResponse, is_logged_in: true, }; - const jsonString = JSON.stringify(loginResponse); @@ -220,8 +221,9 @@ describe('identity-utils', () => { expect(cachedLoginCall.status).to.equal(200); expect(cachedLoginCall.expireTimestamp).to.equal(currentTime); - const responseText = JSON.parse(cachedLoginCall.responseText); - expect(responseText).to.deep.equal(loginResponse); + const cachedResponseText = JSON.parse(cachedLoginCall.responseText); + const expectedResponseText = {mpid: testMPID, is_logged_in: true}; + expect(cachedResponseText).to.deep.equal(expectedResponseText); }); });