fixing router
This commit is contained in:
parent
bc5bae34aa
commit
bb158a9765
1 changed files with 5 additions and 4 deletions
|
|
@ -4,7 +4,7 @@ import MapView from '@/views/MapView.vue'
|
|||
import MainView from '@/views/MainView.vue'
|
||||
const loginView = () => import('@/views/login.vue')
|
||||
|
||||
import { authenticated, logout } from '@/plugins/auth'
|
||||
import { authenticated } from '@/plugins/auth'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
|
@ -81,10 +81,11 @@ const router = createRouter({
|
|||
})
|
||||
|
||||
// authen with keycloak client
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.meta.Auth) {
|
||||
if (authenticated === undefined && to.meta.Auth) {
|
||||
logout()
|
||||
const checkAuthen = await authenticated()
|
||||
if (!checkAuthen && to.meta.Auth) {
|
||||
router.push({ name: 'loginMain' })
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue