This commit is contained in:
Nadar
2026-03-17 13:24:22 +03:00
commit 82e5ac9d81
554 changed files with 29637 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
export default defineNuxtRouteMiddleware(async (to, from) => {
if (to.path === '/')
return navigateTo('/projects')
if (to.path !== '/' && to.path.endsWith('/'))
return navigateTo(to.path.slice(0, -1))
})

View File

@@ -0,0 +1,17 @@
import type { User } from '~/composables/use-auth'
export default defineNuxtRouteMiddleware(async (to, from) => {
const session = useCookie('session')
const { authenticated, user } = useAuth()
if (session.value && !authenticated.value) {
try {
user.value = await $api<User>('/users/current', {
method: 'get',
})
}
catch (e) {
console.log(e)
}
}
})

View File

@@ -0,0 +1,6 @@
export default defineNuxtRouteMiddleware(async (to, from) => {
const { authenticated } = useAuth()
if (!authenticated.value)
return navigateTo('/login')
})

View File

@@ -0,0 +1,6 @@
export default defineNuxtRouteMiddleware(() => {
const { authenticated } = useAuth()
if (authenticated.value)
return navigateTo('/projects')
})