This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-23 15:20:52 +07:00
parent 1dc208233c
commit 8f103aeb71
8 changed files with 136 additions and 40 deletions

View file

@ -47,7 +47,7 @@ const router = createRouter({
Key: [7],
},
},
...ModuleTransfer,
...ModuleRetire,
...ModuleCheckin,
@ -68,27 +68,23 @@ const router = createRouter({
name: "loginMain",
component: loginMain,
meta: {
Auth: true,
Auth: false,
Key: [7],
},
},
],
});
// authen with keycloak client
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 {
next();
if (keycloak.authenticated === undefined && to.meta.Auth) {
window.location.href = "/login";
}
} else {
next();
}
// next();
next();
});
export default router;