refactor: move redirect to root
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
committed by
Patrik Oldsberg
parent
f17da85b08
commit
60167a3980
@@ -48,6 +48,7 @@
|
||||
"@backstage/plugin-airbrake": "workspace:^",
|
||||
"@backstage/plugin-apache-airflow": "workspace:^",
|
||||
"@backstage/plugin-api-docs": "workspace:^",
|
||||
"@backstage/plugin-auth-react": "workspace:^",
|
||||
"@backstage/plugin-azure-devops": "workspace:^",
|
||||
"@backstage/plugin-azure-sites": "workspace:^",
|
||||
"@backstage/plugin-badges": "workspace:^",
|
||||
|
||||
@@ -21,16 +21,14 @@ import {
|
||||
OAuthRequestDialog,
|
||||
SignInPage,
|
||||
} from '@backstage/core-components';
|
||||
import { RedirectToRoot } from '@backstage/plugin-auth-react';
|
||||
import React from 'react';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { providers } from '../src/identityProviders';
|
||||
import {
|
||||
configApiRef,
|
||||
createApiFactory,
|
||||
discoveryApiRef,
|
||||
identityApiRef,
|
||||
useApi,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { AuthProxyDiscoveryApi } from '../src/AuthProxyDiscoveryApi';
|
||||
|
||||
@@ -56,36 +54,6 @@ const app = createApp({
|
||||
},
|
||||
});
|
||||
|
||||
function RedirectToRoot() {
|
||||
const identityApi = useApi(identityApiRef);
|
||||
|
||||
const { value, loading, error } = useAsync(async () => {
|
||||
const { token } = await identityApi.getCredentials();
|
||||
if (!token) {
|
||||
throw new Error('Expected Backstage token in sign-in response');
|
||||
}
|
||||
return token;
|
||||
}, [identityApi]);
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
} else if (error) {
|
||||
return <>An error occurred: {error}</>;
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
ref={form => form?.submit()}
|
||||
action={window.location.href}
|
||||
method="POST"
|
||||
>
|
||||
<input type="hidden" name="type" value="sign-in" />
|
||||
<input type="hidden" name="token" value={value} />
|
||||
<input type="submit" value="Continue" />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
const App = app.createRoot(
|
||||
<>
|
||||
<AlertDisplay transientTimeoutMs={2500} />
|
||||
|
||||
Reference in New Issue
Block a user