UNPKG

wakeb-starter-cli

Version:

A powerful CLI tool for generating CRUD modules, common modules, and components with Vue 3 form schemas, featuring intelligent field detection and automatic schema generation

20 lines (17 loc) 552 B
import { useAuthStore } from '../stores/auth' import auth from '../router' export async function authGuard(to, from, next) { const authStore = useAuthStore() const { user, isAuthenticated } = authStore if (to.path === from.path) return next() const authRoutes = auth.map((route) => route.path) if (isAuthenticated) { if (authRoutes.includes(to.path)) return next('/') return next() } if (to.meta.requiresAuth) { if (!user?.email || !isAuthenticated) return next('/login') return next() } next() }