feat: improve authentication
All checks were successful
Build Test / build (pull_request) Successful in 43s
JS Unit Tests / test (pull_request) Successful in 41s
PHP Unit Tests / test (pull_request) Successful in 49s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-19 23:03:09 -05:00
parent decda8becc
commit 99fa707eb3
7 changed files with 194 additions and 175 deletions

View File

@@ -9,15 +9,12 @@ import { useTenantStore } from '@KTXC/stores/tenantStore'
import { useUserStore } from '@KTXC/stores/userStore'
import { fetchWrapper } from '@KTXC/utils/helpers/fetch-wrapper'
import { initializeModules } from '@KTXC/utils/modules'
import { createSessionMonitor } from '@KTXC/services/authManager'
import App from './App.vue'
import router from './router'
import vuetify from './plugins/vuetify/index'
import '@KTXC/scss/style.scss'
// Material Design Icons (Vuetify mdi icon set)
import '@mdi/font/css/materialdesignicons.min.css'
// google-fonts
import '@fontsource/public-sans/index.css'
const app = createApp(App)
@@ -26,8 +23,6 @@ app.use(pinia)
app.use(PerfectScrollbarPlugin)
app.use(vuetify)
// Note: Router is registered AFTER modules are loaded to prevent premature route matching
const globalWindow = window as typeof window & {
[key: string]: unknown
}
@@ -37,7 +32,6 @@ globalWindow.vue = Vue
globalWindow.VueRouter = VueRouterLib
globalWindow.Pinia = PiniaLib as unknown
// Bootstrap initial private UI state (modules, tenant, user) before mounting
(async () => {
const moduleStore = useModuleStore();
const tenantStore = useTenantStore();
@@ -48,23 +42,23 @@ globalWindow.Pinia = PiniaLib as unknown
moduleStore.init(payload?.modules ?? {});
tenantStore.init(payload?.tenant ?? null);
userStore.init(payload?.user ?? {});
// Initialize auth session monitor
const sessionMonitor = createSessionMonitor({ onLogout: () => userStore.logout() });
sessionMonitor.start();
// Initialize registered modules (following reference app's bootstrap pattern)
// Initialize registered modules
await initializeModules(app);
// Add 404 catch-all route AFTER all modules are loaded
// This ensures module routes are registered before the catch-all
// Register a catch-all and router
router.addRoute({
name: 'NotFound',
path: '/:pathMatch(.*)*',
component: () => import('@KTXC/views/pages/maintenance/error/Error404Page.vue')
});
// Register router AFTER modules are loaded
app.use(router);
await router.isReady();
// Home redirect handled by router beforeEnter
app.mount('#app');
} catch (e) {
console.error('Bootstrap failed:', e);