diff --git a/src/main.ts b/src/main.ts index b5b7a7b..9ae5ac6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -59,7 +59,6 @@ if (kcToken && kcRefreshToken) { token: kcToken, refreshToken: kcRefreshToken, }) - keycloak.authenticated = true // .then((authenticated) => { // console.log('authenticated', authenticated) // if (!authenticated) { @@ -71,8 +70,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 ced0e07..aca6c7f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -86,7 +86,7 @@ router.beforeEach((to, from, next) => { console.log('keycloak==>', keycloak.authenticated) if (to.meta.Auth) { - if (keycloak.authenticated === false && to.meta.Auth) { + if (keycloak.authenticated === undefined && to.meta.Auth) { window.location.href = '/login' } } else {