From 8154b05a950b0a8db0796031355326d5f0ec68ad Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 10 Nov 2023 11:43:40 +0530 Subject: [PATCH 1/2] fix: handle if extra prop is missing in response --- packages/nc-gui/middleware/auth.global.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/middleware/auth.global.ts b/packages/nc-gui/middleware/auth.global.ts index 3ab3d1cf50..dad1a3b92d 100644 --- a/packages/nc-gui/middleware/auth.global.ts +++ b/packages/nc-gui/middleware/auth.global.ts @@ -137,7 +137,7 @@ async function tryGoogleAuth(api: Api, signIn: Actions['signIn']) { data: { token, extra }, } = await api.instance.post(`/auth/${authProvider}/genTokenByCode${window.location.search}`) - extraProps = extra + extraProps = extra || {} signIn(token) } catch (e: any) { @@ -148,7 +148,7 @@ async function tryGoogleAuth(api: Api, signIn: Actions['signIn']) { window.history.pushState( 'object', document.title, - `${extraProps.continueAfterSignIn ? `${newURL}#/?continueAfterSignIn=${extraProps.continueAfterSignIn}` : newURL}`, + `${extraProps?.continueAfterSignIn ? `${newURL}#/?continueAfterSignIn=${extraProps.continueAfterSignIn}` : newURL}`, ) window.location.reload() } From e942ede3dd3b9d4ad99bea6bac60e296d1bcaaa7 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 11 Nov 2023 11:11:27 +0530 Subject: [PATCH 2/2] refactor: add some comment --- packages/nc-gui/middleware/auth.global.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/nc-gui/middleware/auth.global.ts b/packages/nc-gui/middleware/auth.global.ts index dad1a3b92d..42b9e4140d 100644 --- a/packages/nc-gui/middleware/auth.global.ts +++ b/packages/nc-gui/middleware/auth.global.ts @@ -133,10 +133,12 @@ async function tryGoogleAuth(api: Api, signIn: Actions['signIn']) { authProvider = 'oidc' } + // `extra` prop is used in our cloud implementation, so we are keeping it const { data: { token, extra }, } = await api.instance.post(`/auth/${authProvider}/genTokenByCode${window.location.search}`) + // if extra prop is null/undefined set it as an empty object as fallback extraProps = extra || {} signIn(token)