From 2fc2bcec105c8066fd2c9f42553b866d3c5dd949 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 7 Oct 2023 12:45:06 +0000 Subject: [PATCH] fix: avoid unnecessary google auth invocation --- packages/nc-gui/middleware/auth.global.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/middleware/auth.global.ts b/packages/nc-gui/middleware/auth.global.ts index c128999bbf..4253c4bf34 100644 --- a/packages/nc-gui/middleware/auth.global.ts +++ b/packages/nc-gui/middleware/auth.global.ts @@ -1,6 +1,7 @@ import type { Api } from 'nocodb-sdk' import type { Actions } from '~/composables/useGlobal/types' import { defineNuxtRouteMiddleware, message, navigateTo, useApi, useGlobal, useRoles } from '#imports' +import { extractSdkResponseErrorMsg } from '~/utils' /** * Global auth middleware @@ -46,7 +47,9 @@ export default defineNuxtRouteMiddleware(async (to, from) => { } /** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */ - if (!state.signedIn.value && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth(api, state.signIn) + if (!state.signedIn.value && state.appInfo.value.googleAuthEnabled) { + await tryGoogleAuth(api, state.signIn) + } /** if public allow all visitors */ if (to.meta.public) return @@ -115,7 +118,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => { * If present, try using google auth data to sign user in before navigating to the next page */ async function tryGoogleAuth(api: Api, signIn: Actions['signIn']) { - /* if (window.location.search && /\bscope=|\bstate=/.test(window.location.search) && /\bcode=/.test(window.location.search)) { + if (window.location.search && /\bscope=|\bstate=/.test(window.location.search) && /\bcode=/.test(window.location.search)) { let extraProps: any = {} try { let authProvider = 'google' @@ -143,5 +146,5 @@ async function tryGoogleAuth(api: Api, signIn: Actions['signIn']) { `${extraProps.continueAfterSignIn ? `${newURL}#/?continueAfterSignIn=${extraProps.continueAfterSignIn}` : newURL}`, ) window.location.reload() - } */ + } }