mirror of https://github.com/nocodb/nocodb
Braks
2 years ago
committed by
Pranav C
3 changed files with 26 additions and 1 deletions
@ -0,0 +1,15 @@ |
|||||||
|
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) |
||||||
|
} |
||||||
|
}) |
Loading…
Reference in new issue