Browse Source

chore(gui-v2): check if signed in before trying google auth

pull/3252/head
braks 2 years ago
parent
commit
5fd4e50c81
  1. 9
      packages/nc-gui-v2/middleware/auth.global.ts

9
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')

Loading…
Cancel
Save