Skip to content

Commit

Permalink
fix(ui): capture and update profile info for oidc users (#19024)
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-madlani authored Dec 13, 2024
1 parent 15e64b5 commit ef5f274
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export const getNameFromUserData = (
}
}

return { name: userName, email: email };
return { name: userName, email: email, picture: user.picture };
};

export const isProtectedRoute = (pathname: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ const userProfile = {

describe('Test Auth Provider utils', () => {
it('getNameFromUserData should return name and email from claim: preferred_username', () => {
const { name, email } = getNameFromUserData(userProfile, [
const { name, email, picture } = getNameFromUserData(userProfile, [
'preferred_username',
]);

expect(name).toEqual('i_am_preferred_username');
expect(email).toEqual('i_am_preferred_username@');
expect(picture).toEqual('');
});

it('getNameFromUserData should return name and email from claim: email', () => {
Expand Down Expand Up @@ -99,6 +100,18 @@ describe('Test Auth Provider utils', () => {
expect(name).toEqual('i_am_preferred_username');
expect(email).toEqual('i_am_preferred_username@test.com');
});

it('getNameFromUserData should return picture details as it is', () => {
const { name, email, picture } = getNameFromUserData(
{ ...userProfile, picture: 'test_picture' },
['preferred_username', 'email', 'sub'],
'test.com'
);

expect(name).toEqual('i_am_preferred_username');
expect(email).toEqual('i_am_preferred_username@test.com');
expect(picture).toEqual('test_picture');
});
});

import { OidcUser } from '../components/Auth/AuthProviders/AuthProvider.interface';
Expand Down

0 comments on commit ef5f274

Please sign in to comment.