ต่อ auth keycloak
This commit is contained in:
parent
04be324441
commit
aecfb85e14
2 changed files with 27 additions and 9 deletions
|
|
@ -3,6 +3,8 @@ import HomeView from '../views/HomeView.vue'
|
|||
import Exam from '@/modules/01_exam/router'
|
||||
import Meta02 from '@/modules/02_meta/router'
|
||||
|
||||
import keycloak from "@/plugins/keycloak";
|
||||
|
||||
const MainLayout = () => import('@/views/MainLayout.vue')
|
||||
|
||||
const router = createRouter({
|
||||
|
|
@ -56,5 +58,21 @@ const router = createRouter({
|
|||
// }
|
||||
// ]
|
||||
// })
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.Auth) {
|
||||
if (!keycloak.authenticated) {
|
||||
keycloak.login({
|
||||
redirectUri: `${window.location.protocol}//${window.location.host}${to.path}`,
|
||||
locale: "th",
|
||||
});
|
||||
} else {
|
||||
// keycloak.updateToken(60);
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
// next();
|
||||
});
|
||||
|
||||
export default router
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue