update auth

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-28 13:43:21 +07:00
parent 23afdc4df9
commit ff3fb68219
12 changed files with 222 additions and 308 deletions

View file

@ -4,7 +4,7 @@ import MapView from '@/views/MapView.vue'
import MainView from '@/views/MainView.vue'
const loginView = () => import('@/views/login.vue')
import keycloak, { kcLogout } from '@/plugins/keycloak'
import { authenticated, logout } from '@/plugins/auth'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@ -82,12 +82,9 @@ const router = createRouter({
// authen with keycloak client
router.beforeEach((to, from, next) => {
// console.log('keycloak==>', keycloak)
console.log('keycloak==>', keycloak.authenticated)
if (to.meta.Auth) {
if (keycloak.authenticated === undefined && to.meta.Auth) {
kcLogout()
if (authenticated === undefined && to.meta.Auth) {
logout()
}
} else {
next()