From 045cc0207624d33ea74a63226baadb8f4c9e5c70 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Tue, 18 May 2021 16:15:07 +0200 Subject: [PATCH] 1. use optional: true when fetching backstageidentity which doesn't prompt sign-up if no session is found 2. use Progress bar when the logic is happening 3. remove redundant showLoginPage Signed-off-by: Himanshu Mishra --- .../core/src/layout/SignInPage/SignInPage.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/core/src/layout/SignInPage/SignInPage.tsx b/packages/core/src/layout/SignInPage/SignInPage.tsx index 74a53b6b45..92041f9a0f 100644 --- a/packages/core/src/layout/SignInPage/SignInPage.tsx +++ b/packages/core/src/layout/SignInPage/SignInPage.tsx @@ -98,7 +98,18 @@ export const SingleSignInPage = ({ useEffect(() => { const login = async () => { try { - const identity = await authApi.getBackstageIdentity(); + let identity; + // Do an initial check if any logged-in session exists + identity = await authApi.getBackstageIdentity({ + optional: true, + }); + + // If no session exists, show the sign-in page + if (!identity) { + identity = await authApi.getBackstageIdentity({ + instantPopup: true, + }); + } const profile = await authApi.getProfile(); onResult({ @@ -111,9 +122,6 @@ export const SingleSignInPage = ({ await authApi.signOut(); }, }); - - // Don't show if login is successful - setShowLoginPage(false); } catch (err) { // User closed the sign-in modal setError(err); @@ -162,7 +170,9 @@ export const SingleSignInPage = ({ - ) : null; + ) : ( + + ); }; export const SignInPage = (props: Props) => {