Skip to content

Commit

Permalink
Merge pull request openedx#12 from edx/robrap/ARCH-379-get-user-id
Browse files Browse the repository at this point in the history
feat(authentication): add userId and drop email
  • Loading branch information
robrap authored Feb 7, 2019
2 parents 950a5f9 + 6561932 commit cdb5436
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AuthenticatedAPIClient/authInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);

const jwt = {
email: '[email protected]',
user_id: '12345',
preferred_username: 'test',
};
const expiredJwt = Object.assign({ exp: yesterday.getTime() / 1000 }, jwt);
Expand Down Expand Up @@ -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);
});

Expand Down
2 changes: 1 addition & 1 deletion src/PrivateRoute/PrivateRoute.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('PrivateRoute', () => {
it('renders private component if authenticated', () => {
const store = mockStore({
authentication: {
email: '[email protected]',
userId: '12345',
username: 'test',
},
});
Expand Down

0 comments on commit cdb5436

Please sign in to comment.