updated check token

This commit is contained in:
Warunee Tamkoo 2024-07-26 14:13:10 +07:00
parent 3718dad5f4
commit 974b64bb80
7 changed files with 93 additions and 46 deletions

View file

@ -3,7 +3,7 @@ import App from "./App.vue";
import router from "./router";
import { Dialog, Notify, Quasar, Loading } from "quasar";
import "./quasar-user-options";
import keycloak from "@/plugins/keycloak";
import keycloak, { getToken } from "@/plugins/keycloak";
import qDraggableTable from "quasar-ui-q-draggable-table";
import "quasar-ui-q-draggable-table/dist/index.css";
@ -100,15 +100,13 @@ 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);