From 5fd4e50c81cdf44d4fea76736e4ab16b5880064f Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 19 Aug 2022 16:05:27 +0200 Subject: [PATCH] chore(gui-v2): check if signed in before trying google auth --- packages/nc-gui-v2/middleware/auth.global.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui-v2/middleware/auth.global.ts b/packages/nc-gui-v2/middleware/auth.global.ts index 3c88944342..d670c48bc6 100644 --- a/packages/nc-gui-v2/middleware/auth.global.ts +++ b/packages/nc-gui-v2/middleware/auth.global.ts @@ -24,16 +24,15 @@ import { useApi, useGlobal } from '#imports' export default defineNuxtRouteMiddleware(async (to, from) => { const state = useGlobal() - await tryGoogleAuth() + /** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */ + if (!state.signedIn && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth() - /** if public allow */ + /** if public allow all visitors */ if (to.meta.public) return - /** if shred base allow without validating */ + /** if shared base allow without validating */ if (to.params?.projectType === 'base') return - if (to.meta.public) return - /** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */ if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !state.signedIn.value) { return navigateTo('/signin')