fixing auth sso

This commit is contained in:
Warunee Tamkoo 2024-07-16 22:29:09 +07:00
parent ede985939a
commit 93cf472aae
3 changed files with 50 additions and 20 deletions

View file

@ -1,7 +1,7 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import MapView from '@/views/MapView.vue'
import MianView from '@/views/MianView.vue'
import MainView from '@/views/MainView.vue'
import keycloak from '@/plugins/keycloak'
@ -11,7 +11,7 @@ const router = createRouter({
{
path: '/',
name: 'home',
component: MianView,
component: MainView,
children: [
{
path: '/',
@ -45,14 +45,14 @@ const router = createRouter({
name: 'history',
component: () => import('@/views/HistoryView.vue'),
meta: {
Auth: true,
Auth: false,
},
},
// {
// path: '/camera',
// name: 'camera',
// component: () => import('@/views/SampleCamera.vue'),
// },
{
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
@ -75,18 +75,18 @@ router.beforeEach((to, from, next) => {
console.log('keycloak===>', keycloak)
console.log('keycloak authenticated===>', keycloak.authenticated)
// if (keycloak.authenticated === undefined) {
// window.location.href = 'https://bma-sso.frappet.synology.me'
// } else {
// // keycloak.updateToken(60);
// // const role = keycloak.tokenParsed?.role
// // if (role.includes(to.meta.Role)) {
// next()
// // } else {
// // next({ path: '' })
// // // next();
// // }
// }
if (keycloak.authenticated === undefined) {
window.location.href = 'https://bma-sso.frappet.synology.me'
// } else {
// // keycloak.updateToken(60);
// // const role = keycloak.tokenParsed?.role
// // if (role.includes(to.meta.Role)) {
// next()
// // } else {
// // next({ path: '' })
// // // next();
// // }
}
} else {
next()
}