add guest auth pages

This commit is contained in:
Yisroel Baum 2026-07-31 09:56:16 +03:00
parent edcaf80b98
commit 02c947708f
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
13 changed files with 1499 additions and 10 deletions

View file

@ -1,8 +1,59 @@
import { createRouter, createWebHistory } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [],
routes: [
{
path: '/',
name: 'home',
component: () => import('@/views/HomeView.vue'),
},
{
path: '/login',
name: 'login',
component: () => import('@/views/LoginView.vue'),
meta: {
guestOnly: true,
},
},
{
path: '/signup',
name: 'signup',
component: () => import('@/views/SignupView.vue'),
meta: {
guestOnly: true,
},
},
{
path: '/dashboard',
name: 'dashboard',
component: () => import('@/views/DashboardView.vue'),
meta: {
requiresAuth: true,
},
},
],
})
router.beforeEach((to) => {
const authStore = useAuthStore()
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
return {
name: 'login',
query: {
redirect: to.fullPath,
},
}
}
if (to.meta.guestOnly && authStore.isAuthenticated) {
return {
name: 'dashboard',
}
}
})
export default router