updated authen with keycloak client
This commit is contained in:
parent
93cf472aae
commit
9ec6a7696a
8 changed files with 378 additions and 32 deletions
|
|
@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
|
|||
import HomeView from '@/views/HomeView.vue'
|
||||
import MapView from '@/views/MapView.vue'
|
||||
import MainView from '@/views/MainView.vue'
|
||||
const loginView = () => import('@/views/login.vue')
|
||||
|
||||
import keycloak from '@/plugins/keycloak'
|
||||
|
||||
|
|
@ -67,25 +68,23 @@ const router = createRouter({
|
|||
},
|
||||
],
|
||||
},
|
||||
// authen with keycloak client
|
||||
{
|
||||
path: '/login',
|
||||
name: 'loginMain',
|
||||
component: loginView,
|
||||
meta: {
|
||||
Auth: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// authen with keycloak client
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.Auth) {
|
||||
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 && to.meta.Auth) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue