Capital/middleware/auth.ts

8 lines
189 B
TypeScript
Raw Permalink Normal View History

2024-08-12 15:51:42 +00:00
export default defineNuxtRouteMiddleware((to, from) => {
2024-08-13 10:26:36 +00:00
const state = useLoggedInState()
2024-08-12 15:51:42 +00:00
2024-08-13 10:26:36 +00:00
if (!state.value) {
2024-08-12 15:51:42 +00:00
return navigateTo(`/auth/sign-in?redirect_uri=${to.fullPath}`)
}
})