feat(portal): strip Vuexy demo content and create clean portal shell
Remove all demo pages, dialogs, sidebar navigation, and layout components. Create minimal top-bar portal layout with auth-aware navigation, placeholder pages for volunteer registration, dashboard, shifts, profile, artist advance, and login. Add Pinia auth store, axios with Sanctum support, and router guards. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
28
apps/portal/src/plugins/1.router/guards.ts
Normal file
28
apps/portal/src/plugins/1.router/guards.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { Router } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/useAuthStore'
|
||||
|
||||
export function setupGuards(router: Router) {
|
||||
router.beforeEach(async (to) => {
|
||||
const authStore = useAuthStore()
|
||||
|
||||
if (!authStore.isInitialized) {
|
||||
await authStore.initialize()
|
||||
}
|
||||
|
||||
const requiresAuth = to.meta.requiresAuth === true
|
||||
|
||||
// Public routes — no auth check needed
|
||||
if (!requiresAuth) {
|
||||
// Redirect authenticated users away from login
|
||||
if (authStore.isAuthenticated && to.path === '/login') {
|
||||
return { path: '/dashboard' }
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Auth required — redirect to login if not authenticated
|
||||
if (!authStore.isAuthenticated) {
|
||||
return { path: '/login', query: { to: to.fullPath } }
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user