feat(#5): use auth

This commit is contained in:
Sirttas
2026-06-28 14:18:09 +02:00
parent e7249df23f
commit 61fbc8e16b
11 changed files with 1263 additions and 26 deletions
+16 -6
View File
@@ -1,9 +1,10 @@
import { createPinia } from 'pinia';
import { createApp } from 'vue';
import { createRouter, createWebHistory } from 'vue-router';
import {createPinia} from 'pinia';
import {createApp} from 'vue';
import {createRouter, createWebHistory} from 'vue-router';
import App from './App.vue';
import { initLogger } from './logger';
import { routes } from './routes';
import {useAuthStore} from './auth';
import {initLogger} from './logger';
import {routeNames, routes} from './routes';
import './style.css';
initLogger();
@@ -18,4 +19,13 @@ const router = createRouter({
app.use(pinia);
app.use(router);
app.mount('#app');
const authStore = useAuthStore();
router.beforeEach(to => {
if (!to.meta.public && !authStore.isAuthenticated) {
return {name: routeNames.home};
}
return true;
});
authStore.bootstrap().finally(() => app.mount('#app'));