fix(ui): capture and update profile info for oidc users (#19024)

This commit is contained in:
Chirag Madlani 2024-12-13 12:45:38 +05:30 committed by GitHub
parent 15e64b5a12
commit ef5f274b11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View File

@ -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) => {

View File

@ -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', () => {
@ -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';