diff --git a/src/AuthenticatedAPIClient/authInterface.js b/src/AuthenticatedAPIClient/authInterface.js index 7c62d135f..70fe9d247 100644 --- a/src/AuthenticatedAPIClient/authInterface.js +++ b/src/AuthenticatedAPIClient/authInterface.js @@ -35,7 +35,7 @@ export default function applyAuthInterface(httpClient, authConfig) { const token = httpClient.getDecodedAccessToken(); if (token) { state.authentication = { - email: token.email, + userId: token.user_id, username: token.preferred_username, }; } diff --git a/src/AuthenticatedAPIClient/tests/AuthenticatedAPIClient.test.jsx b/src/AuthenticatedAPIClient/tests/AuthenticatedAPIClient.test.jsx index 2a8b6b6a6..ae53dd37f 100644 --- a/src/AuthenticatedAPIClient/tests/AuthenticatedAPIClient.test.jsx +++ b/src/AuthenticatedAPIClient/tests/AuthenticatedAPIClient.test.jsx @@ -19,7 +19,7 @@ const tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); const jwt = { - email: 'test@example.com', + user_id: '12345', preferred_username: 'test', }; const expiredJwt = Object.assign({ exp: yesterday.getTime() / 1000 }, jwt); @@ -156,7 +156,9 @@ describe('AuthenticatedAPIClient auth interface', () => { it('has method getAuthenticationState that returns authentication state when valid JWT cookie exists', () => { mockCookies.get.mockReturnValueOnce(encodedValidJwt); const result = client.getAuthenticationState(); - expect(result.authentication.email).toEqual(validJwt.email); + expect(result.authentication.userId).toBeDefined(); + expect(result.authentication.userId).toEqual(validJwt.user_id); + expect(result.authentication.username).toBeDefined(); expect(result.authentication.username).toEqual(validJwt.preferred_username); }); diff --git a/src/PrivateRoute/PrivateRoute.test.jsx b/src/PrivateRoute/PrivateRoute.test.jsx index 290fca512..8d1500d97 100644 --- a/src/PrivateRoute/PrivateRoute.test.jsx +++ b/src/PrivateRoute/PrivateRoute.test.jsx @@ -42,7 +42,7 @@ describe('PrivateRoute', () => { it('renders private component if authenticated', () => { const store = mockStore({ authentication: { - email: 'test@example.com', + userId: '12345', username: 'test', }, });