authentication providers page to reflect status

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2023-05-19 11:07:03 +01:00
parent 6c0867be8d
commit 7a8441b9a3
2 changed files with 12 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-user-settings': patch
---
Reflect the updated sign on status for a provider after signing out.
@@ -37,6 +37,8 @@ import {
} from '@backstage/core-plugin-api';
import { ProviderSettingsAvatar } from './ProviderSettingsAvatar';
const emptyProfile: ProfileInfo = {};
/** @public */
export const ProviderSettingsItem = (props: {
title: string;
@@ -49,8 +51,7 @@ export const ProviderSettingsItem = (props: {
const api = useApi(apiRef);
const errorApi = useApi(errorApiRef);
const [signedIn, setSignedIn] = useState(false);
const emptyProfile: ProfileInfo = {};
const [profile, setProfile] = useState(emptyProfile);
const [profile, setProfile] = useState<ProfileInfo>(emptyProfile);
useEffect(() => {
let didCancel = false;
@@ -58,6 +59,10 @@ export const ProviderSettingsItem = (props: {
const subscription = api
.sessionState$()
.subscribe((sessionState: SessionState) => {
if (sessionState !== SessionState.SignedIn) {
setProfile(emptyProfile);
setSignedIn(false);
}
if (!didCancel) {
api
.getProfile({ optional: true })