updateAuthen

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-25 12:58:04 +07:00
parent 892b1d507c
commit 7e2350eef8
5 changed files with 99 additions and 57 deletions

View file

@ -98,24 +98,27 @@ 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) {
window.location.reload();
} else {
console.log("Authenticated");
}
})
.catch((err) => {
console.error("Keycloak initialization failed:", err);
});
keycloak.init({
// onLoad: 'login-required',
checkLoginIframe: false,
token: kcToken,
refreshToken: kcRefreshToken,
});
keycloak.authenticated = true;
// .then((authenticated) => {
// console.log("authenticated", authenticated);
// if (!authenticated) {
// window.location.reload();
// } else {
// console.log("Authenticated");
// }
// })
// .catch((err) => {
// console.error("Keycloak initialization failed:", err);
// });
} else {
keycloak.authenticated = false;
}
app.mount("#app");