|
|
@ -1,6 +1,7 @@ |
|
|
|
import type { Api } from 'nocodb-sdk' |
|
|
|
import type { Api } from 'nocodb-sdk' |
|
|
|
import type { Actions } from '~/composables/useGlobal/types' |
|
|
|
import type { Actions } from '~/composables/useGlobal/types' |
|
|
|
import { defineNuxtRouteMiddleware, message, navigateTo, useApi, useGlobal, useRoles } from '#imports' |
|
|
|
import { defineNuxtRouteMiddleware, message, navigateTo, useApi, useGlobal, useRoles } from '#imports' |
|
|
|
|
|
|
|
import { extractSdkResponseErrorMsg } from '~/utils' |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Global auth middleware |
|
|
|
* 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 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 public allow all visitors */ |
|
|
|
if (to.meta.public) return |
|
|
|
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 |
|
|
|
* If present, try using google auth data to sign user in before navigating to the next page |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async function tryGoogleAuth(api: Api<any>, signIn: Actions['signIn']) { |
|
|
|
async function tryGoogleAuth(api: Api<any>, 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 = {} |
|
|
|
let extraProps: any = {} |
|
|
|
try { |
|
|
|
try { |
|
|
|
let authProvider = 'google' |
|
|
|
let authProvider = 'google' |
|
|
@ -143,5 +146,5 @@ async function tryGoogleAuth(api: Api<any>, signIn: Actions['signIn']) { |
|
|
|
`${extraProps.continueAfterSignIn ? `${newURL}#/?continueAfterSignIn=${extraProps.continueAfterSignIn}` : newURL}`, |
|
|
|
`${extraProps.continueAfterSignIn ? `${newURL}#/?continueAfterSignIn=${extraProps.continueAfterSignIn}` : newURL}`, |
|
|
|
) |
|
|
|
) |
|
|
|
window.location.reload() |
|
|
|
window.location.reload() |
|
|
|
} */ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|