fixing check token

This commit is contained in:
Warunee Tamkoo 2024-07-26 14:17:03 +07:00
parent 04da1988b0
commit 00cb0c6f23
7 changed files with 83 additions and 66 deletions

View file

@ -3,7 +3,7 @@ import App from '@/App.vue'
import '@/registerServiceWorker'
import router from '@/router'
import { createPinia } from 'pinia'
import keycloak from '@/plugins/keycloak'
import keycloak, { getToken } from '@/plugins/keycloak'
import { Quasar, Dialog, Notify, Loading } from 'quasar'
import '@vuepic/vue-datepicker/dist/main.css'
@ -49,16 +49,15 @@ function getCookie(name: string) {
return null
}
const kcToken = getCookie('BMAHRIS_KEYCLOAK_IDENTITY')
const kcRefreshToken = getCookie('BMAHRIS_KEYCLOAK_REFRESH')
const auth = await getToken()
if (kcToken && kcRefreshToken) {
if (auth.token && auth.refresh_token) {
keycloak.init({
// onLoad: 'login-required',
checkLoginIframe: false,
token: kcToken,
refreshToken: kcRefreshToken,
token: auth.token,
refreshToken: auth.refresh_token,
})
// .then((authenticated) => {
// console.log('authenticated', authenticated)
// if (!authenticated) {