feat(app): auth, orgs/events UI, router guards, and dev tooling
- Add Sanctum auth flow (store, composables, login, axios interceptors) - Add dashboard, organisation list/detail, events CRUD dialogs - Wire router guards, navigation, organisation switcher in layout - Replace Vuexy @db types in NavSearchBar; add @iconify/types; themeConfig title typing - Vuetify settings.scss + resolve configFile via fileURLToPath; drop dead path aliases - Root index redirects to dashboard; fix events table route name - API: DevSeeder + DatabaseSeeder updates; docs TEST_SCENARIO; corporate identity assets Made-with: Cursor
This commit is contained in:
19
apps/app/src/plugins/1.router/guards.ts
Normal file
19
apps/app/src/plugins/1.router/guards.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { Router } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/useAuthStore'
|
||||
|
||||
export function setupGuards(router: Router) {
|
||||
router.beforeEach((to) => {
|
||||
const authStore = useAuthStore()
|
||||
const isPublic = to.meta.public === true
|
||||
|
||||
// Guest-only pages (login): redirect to home if already authenticated
|
||||
if (isPublic && authStore.isAuthenticated) {
|
||||
return { name: 'dashboard' }
|
||||
}
|
||||
|
||||
// Protected pages: redirect to login if not authenticated
|
||||
if (!isPublic && !authStore.isAuthenticated) {
|
||||
return { path: '/login', query: { to: to.fullPath } }
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import type { App } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router/auto'
|
||||
|
||||
import { createRouter, createWebHistory } from 'vue-router/auto'
|
||||
import { setupGuards } from './guards'
|
||||
|
||||
function recursiveLayouts(route: RouteRecordRaw): RouteRecordRaw {
|
||||
if (route.children) {
|
||||
@@ -29,6 +30,8 @@ const router = createRouter({
|
||||
],
|
||||
})
|
||||
|
||||
setupGuards(router)
|
||||
|
||||
export { router }
|
||||
|
||||
export default function (app: App) {
|
||||
|
||||
Reference in New Issue
Block a user