core-components: fall back to using idToken for backwards compatibility

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-08-04 13:51:23 +02:00
parent b2089b89f4
commit 192b13b780
3 changed files with 8 additions and 4 deletions
@@ -130,7 +130,9 @@ export const SingleSignInPage = ({
userId: identity!.id,
profile: profile!,
getIdToken: () => {
return authApi.getBackstageIdentity().then(i => i!.token);
return authApi
.getBackstageIdentity()
.then(i => i!.token ?? i!.idToken);
},
signOut: async () => {
await authApi.signOut();
@@ -40,7 +40,7 @@ const Component: ProviderComponent = ({ onResult }) => {
userId: identity!.id,
profile: profile!,
getIdToken: () =>
auth0AuthApi.getBackstageIdentity().then(i => i!.token),
auth0AuthApi.getBackstageIdentity().then(i => i!.token ?? i!.idToken),
signOut: async () => {
await auth0AuthApi.signOut();
},
@@ -82,7 +82,8 @@ const loader: ProviderLoader = async apis => {
return {
userId: identity.id,
profile: profile!,
getIdToken: () => auth0AuthApi.getBackstageIdentity().then(i => i!.token),
getIdToken: () =>
auth0AuthApi.getBackstageIdentity().then(i => i!.token ?? i!.idToken),
signOut: async () => {
await auth0AuthApi.signOut();
},
@@ -86,7 +86,8 @@ const loader: ProviderLoader = async (apis, apiRef) => {
return {
userId: identity.id,
profile: profile!,
getIdToken: () => authApi.getBackstageIdentity().then(i => i!.token),
getIdToken: () =>
authApi.getBackstageIdentity().then(i => i!.token ?? i!.idToken),
signOut: async () => {
await authApi.signOut();
},