updated sso
This commit is contained in:
parent
06b0e1dcbd
commit
6538140333
6 changed files with 111 additions and 94 deletions
36
src/main.ts
36
src/main.ts
|
|
@ -3,6 +3,7 @@ import App from '@/App.vue'
|
|||
import '@/registerServiceWorker'
|
||||
import router from '@/router'
|
||||
import { createPinia } from 'pinia'
|
||||
import keycloak from '@/plugins/keycloak'
|
||||
|
||||
import { Quasar, Dialog, Notify, Loading } from 'quasar'
|
||||
import '@vuepic/vue-datepicker/dist/main.css'
|
||||
|
|
@ -31,9 +32,42 @@ app.use(Quasar, {
|
|||
|
||||
app.component(
|
||||
'datepicker',
|
||||
defineAsyncComponent(() => import('@vuepic/vue-datepicker')),
|
||||
defineAsyncComponent(() => import('@vuepic/vue-datepicker'))
|
||||
)
|
||||
|
||||
app.config.globalProperties.$http = http
|
||||
|
||||
function getCookie(name: string) {
|
||||
const nameEQ = name + '='
|
||||
const ca = document.cookie.split(';')
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i]
|
||||
while (c.charAt(0) == ' ') c = c.substring(1, c.length)
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const kcToken = getCookie('BMAHRIS_KEYCLOAK_IDENTITY')
|
||||
const kcRefreshToken = getCookie('BMAHRIS_KEYCLOAK_REFRESH')
|
||||
|
||||
if (kcToken && kcRefreshToken) {
|
||||
keycloak
|
||||
.init({
|
||||
// onLoad: 'login-required',
|
||||
checkLoginIframe: false,
|
||||
token: kcToken,
|
||||
refreshToken: kcRefreshToken,
|
||||
})
|
||||
.then((authenticated) => {
|
||||
console.log('authenticated', authenticated)
|
||||
// // // if (authenticated) {
|
||||
// // // app.mount('#app')
|
||||
// // // }
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Keycloak initialization failed:', err)
|
||||
})
|
||||
}
|
||||
|
||||
app.mount('#app')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue