fixing check token

This commit is contained in:
Warunee Tamkoo 2024-07-26 10:04:37 +07:00
parent a12177a940
commit 98452b7878
2 changed files with 1 additions and 4 deletions

View file

@ -110,7 +110,6 @@ if (kcToken && kcRefreshToken) {
token: kcToken, token: kcToken,
refreshToken: kcRefreshToken, refreshToken: kcRefreshToken,
}); });
keycloak.authenticated = true;
// .then((authenticated) => { // .then((authenticated) => {
// console.log("authenticated", authenticated); // console.log("authenticated", authenticated);
// if (!authenticated) { // if (!authenticated) {
@ -122,8 +121,6 @@ if (kcToken && kcRefreshToken) {
// .catch((err) => { // .catch((err) => {
// console.error("Keycloak initialization failed:", err); // console.error("Keycloak initialization failed:", err);
// }); // });
} else {
keycloak.authenticated = false;
} }
app.mount("#app"); app.mount("#app");

View file

@ -74,7 +74,7 @@ const router = createRouter({
// authen with keycloak client // authen with keycloak client
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.meta.Auth) { if (to.meta.Auth) {
if (keycloak.authenticated === false && to.meta.Auth) { if (keycloak.authenticated === undefined && to.meta.Auth) {
window.location.href = "/login"; window.location.href = "/login";
} }
} else { } else {