fix: changed configs
This commit is contained in:
@ -1,69 +1,37 @@
|
||||
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';
|
||||
import axios from "axios";
|
||||
import {useAuthStore} from "@/stores/authStore.ts";
|
||||
let store: any;
|
||||
|
||||
keycloakService.CallInit(() => {
|
||||
try {
|
||||
const app = createApp(App)
|
||||
|
||||
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 });
|
||||
store = useAuthStore();
|
||||
app.use(router)
|
||||
|
||||
|
||||
// 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');
|
||||
app.mount('#app');
|
||||
} catch (e) {
|
||||
console.error("Error while initiating Keycloak.")
|
||||
console.error(e)
|
||||
createApp(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'
|
||||
}
|
||||
} );
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
export {store};
|
Reference in New Issue
Block a user