mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-13 00:22:23 +00:00
fix(ui): msal authentictor to share UserProfile object on login success (#17302)
This commit is contained in:
parent
a98a39fc11
commit
92b2c6c353
@ -18,6 +18,7 @@ import {
|
|||||||
} from '@azure/msal-browser';
|
} from '@azure/msal-browser';
|
||||||
import { useAccount, useMsal } from '@azure/msal-react';
|
import { useAccount, useMsal } from '@azure/msal-react';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
|
import { get } from 'lodash';
|
||||||
import React, {
|
import React, {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
Fragment,
|
Fragment,
|
||||||
@ -34,6 +35,7 @@ import { Transi18next } from '../../../utils/CommonUtils';
|
|||||||
import {
|
import {
|
||||||
AuthenticatorRef,
|
AuthenticatorRef,
|
||||||
OidcUser,
|
OidcUser,
|
||||||
|
UserProfile,
|
||||||
} from '../AuthProviders/AuthProvider.interface';
|
} from '../AuthProviders/AuthProvider.interface';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -80,15 +82,21 @@ const MsalAuthenticator = forwardRef<AuthenticatorRef, Props>(
|
|||||||
const parseResponse = (response: AuthenticationResult): OidcUser => {
|
const parseResponse = (response: AuthenticationResult): OidcUser => {
|
||||||
// Call your API with the access token and return the data you need to save in state
|
// Call your API with the access token and return the data you need to save in state
|
||||||
const { idToken, scopes, account } = response;
|
const { idToken, scopes, account } = response;
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
id_token: idToken,
|
id_token: idToken,
|
||||||
scope: scopes.join(),
|
scope: scopes.join(),
|
||||||
profile: {
|
profile: {
|
||||||
email: account?.username || '',
|
email: get(account, 'idTokenClaims.email', ''),
|
||||||
name: account?.name || '',
|
name: account?.name || '',
|
||||||
picture: '',
|
picture: '',
|
||||||
sub: '',
|
preferred_username: get(
|
||||||
},
|
account,
|
||||||
|
'idTokenClaims.preferred_username',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
sub: get(account, 'idTokenClaims.sub', ''),
|
||||||
|
} as UserProfile,
|
||||||
};
|
};
|
||||||
|
|
||||||
setOidcToken(idToken);
|
setOidcToken(idToken);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user