70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
import { createApp } from 'vue'
|
|
import App from './App.vue'
|
|
import router from './router'
|
|
//import VueKeyCloak from '@dsb-norge/vue-keycloak-js'
|
|
//import { useKeycloak } from '@dsb-norge/vue-keycloak-js'
|
|
//import axios from 'axios'
|
|
import {createPinia} from "pinia";
|
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
|
import AuthStorePlugin from './plugins/authStore';
|
|
import keycloakService from './services/keycloak';
|
|
|
|
keycloakService.CallInit(() => {
|
|
|
|
const app = createApp(App)
|
|
|
|
|
|
// Setup pinia store, allowing user to keep logged in status after refresh
|
|
const pinia = createPinia();
|
|
pinia.use(piniaPluginPersistedstate);
|
|
|
|
app.use(pinia);
|
|
app.use(AuthStorePlugin, { pinia });
|
|
app.use(router)
|
|
app.mount('#app');
|
|
|
|
})
|
|
|
|
createApp(App).mount('#app');
|
|
|
|
// TODO: fix the comment
|
|
/*
|
|
function tokenInterceptor () {
|
|
axios.interceptors.request.use(config => {
|
|
const keycloak = useKeycloak()
|
|
if (keycloak.authenticated) {
|
|
// Note that this is a simple example.
|
|
// you should be careful not to leak tokens to third parties.
|
|
// in this example the token is added to all usage of axios.
|
|
config.headers.Authorization = `Bearer ${keycloak.token}`
|
|
}
|
|
return config
|
|
}, error => {
|
|
console.error("tokenInterceptor: Rejected")
|
|
return Promise.reject(error)
|
|
})
|
|
}
|
|
*/
|
|
|
|
/*
|
|
app.use(VueKeyCloak,{
|
|
onReady: (keycloak) => {
|
|
console.log("Ready !")
|
|
tokenInterceptor()
|
|
},
|
|
init: {
|
|
onLoad: 'login-required',
|
|
checkLoginIframe: false,
|
|
|
|
},
|
|
|
|
config: {
|
|
realm: 'test',
|
|
url: 'http://localhost:7080',
|
|
clientId: 'myinpulse'
|
|
}
|
|
} );
|
|
*/
|
|
|
|
|