fixing check token
This commit is contained in:
parent
56aa900ea3
commit
1a8a380f24
7 changed files with 112 additions and 77 deletions
24
src/main.ts
24
src/main.ts
|
|
@ -9,7 +9,7 @@ import "@vuepic/vue-datepicker/dist/main.css";
|
|||
|
||||
import "quasar/src/css/index.sass";
|
||||
import http from "./plugins/http";
|
||||
import keycloak from "@/plugins/keycloak";
|
||||
import keycloak, { getToken } from "@/plugins/keycloak";
|
||||
|
||||
// import OpenLayersMap from "vue3-openlayers";
|
||||
|
||||
|
|
@ -43,28 +43,14 @@ app.component(
|
|||
app.config.globalProperties.$http = http;
|
||||
|
||||
// authen with keycloak client
|
||||
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 auth = await getToken();
|
||||
|
||||
const kcToken = getCookie("BMAHRIS_KEYCLOAK_IDENTITY");
|
||||
const kcRefreshToken = getCookie("BMAHRIS_KEYCLOAK_REFRESH");
|
||||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue