core-components: allow guest auth without backend

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-04-23 19:36:02 +02:00
parent 1d02904ffd
commit 5b7b49b897
2 changed files with 15 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
The `SignInPage` guest provider will now fall back to legacy guest auth if the backend request fails, allowing guest auth without a running backend.
@@ -60,7 +60,11 @@ const Component: ProviderComponent = ({
discoveryApi,
});
const identityResponse = await getIdentity(identity);
const identityResponse = await getIdentity(identity).catch(error => {
// eslint-disable-next-line no-console
console.warn(`Failed to sign in as a guest, ${error}`);
return undefined;
});
if (!identityResponse) {
// eslint-disable-next-line no-alert
@@ -108,7 +112,11 @@ const loader: ProviderLoader = async apis => {
provider: 'guest',
discoveryApi: apis.get(discoveryApiRef)!,
});
const identityResponse = await getIdentity(identity);
const identityResponse = await getIdentity(identity).catch(error => {
// eslint-disable-next-line no-console
console.warn(`Failed to sign in as a guest, ${error}`);
return undefined;
});
if (!identityResponse && !useLegacyGuestToken) {
return undefined;