initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
const { loggedIn } = useAuth()
|
||||
|
||||
// if authenticated, and on a signin/signup page, redirect to home page
|
||||
if (to.path.toLowerCase().includes('/auth/') && loggedIn.value) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
|
||||
// If not authenticated, and not on a signin/signup page, redirect to login page
|
||||
if (!loggedIn.value && !to.path.toLowerCase().includes('/auth/')) {
|
||||
return navigateTo('/auth/login')
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user