mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
561 B
16 lines
561 B
2 years ago
|
import { defineNuxtRouteMiddleware, navigateTo, useNuxtApp } from '#app'
|
||
|
|
||
|
export default defineNuxtRouteMiddleware((to, from) => {
|
||
|
const { $state } = useNuxtApp()
|
||
|
|
||
|
/**
|
||
|
* By default, we assume that auth is required
|
||
|
* If not required, mark the page as `requiresAuth: false` using `definePageMeta`
|
||
|
*/
|
||
|
if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !$state.signedIn.value) {
|
||
|
return navigateTo('/signin')
|
||
|
} else if (to.meta.requiresAuth === false && $state.signedIn.value) {
|
||
|
return navigateTo(from.path)
|
||
|
}
|
||
|
})
|