Files
memberApp/src/boot/auth.ts
Adrian Zürcher bdcceb53e0 change whole backend and tables for gorm table references
simplify tables with table components close #31
2025-11-29 15:59:18 +01:00

30 lines
807 B
TypeScript

import { boot } from 'quasar/wrappers';
import { appApi } from './axios';
import { createPinia } from 'pinia';
import { useUserStore } from 'src/vueLib/login/userStore';
import { useLogin } from 'src/vueLib/login/useLogin';
const pinia = createPinia();
export default boot(async ({ app }) => {
app.use(pinia);
const useStore = useUserStore();
const login = useLogin();
await appApi
.get('/login/me')
.then((resp) => {
useStore
.setUser({
id: resp.data.id,
username: resp.data.username,
role: { role: resp.data.role, permissions: [] },
})
.catch((err) => console.error(err));
login.refresh().catch((err) => console.error(err));
})
.catch(() => {
login.logout().catch((err) => console.error(err));
});
});