diff --git a/src/main.ts b/src/main.ts index 145ffe3e..94745b3d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -110,7 +110,6 @@ if (kcToken && kcRefreshToken) { token: kcToken, refreshToken: kcRefreshToken, }); - keycloak.authenticated = true; // .then((authenticated) => { // console.log("authenticated", authenticated); // if (!authenticated) { @@ -122,8 +121,6 @@ if (kcToken && kcRefreshToken) { // .catch((err) => { // console.error("Keycloak initialization failed:", err); // }); -} else { - keycloak.authenticated = false; } app.mount("#app"); diff --git a/src/router/index.ts b/src/router/index.ts index 33e3839b..8c3739a3 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -74,7 +74,7 @@ const router = createRouter({ // authen with keycloak client router.beforeEach((to, from, next) => { if (to.meta.Auth) { - if (keycloak.authenticated === false && to.meta.Auth) { + if (keycloak.authenticated === undefined && to.meta.Auth) { window.location.href = "/login"; } } else {