fixing check token
This commit is contained in:
parent
04da1988b0
commit
00cb0c6f23
7 changed files with 83 additions and 66 deletions
|
|
@ -4,7 +4,7 @@ import MapView from '@/views/MapView.vue'
|
|||
import MainView from '@/views/MainView.vue'
|
||||
const loginView = () => import('@/views/login.vue')
|
||||
|
||||
import keycloak from '@/plugins/keycloak'
|
||||
import keycloak, { kcLogout } from '@/plugins/keycloak'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
|
@ -49,11 +49,6 @@ const router = createRouter({
|
|||
Auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/auth',
|
||||
name: 'auth',
|
||||
component: () => import('@/views/auth.vue'),
|
||||
},
|
||||
/**
|
||||
* 404 Not Found
|
||||
* ref: https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route
|
||||
|
|
@ -77,6 +72,11 @@ const router = createRouter({
|
|||
Auth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/auth',
|
||||
name: 'auth',
|
||||
component: () => import('@/views/auth.vue'),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ router.beforeEach((to, from, next) => {
|
|||
|
||||
if (to.meta.Auth) {
|
||||
if (keycloak.authenticated === undefined && to.meta.Auth) {
|
||||
window.location.href = '/login'
|
||||
kcLogout()
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue