login
This commit is contained in:
parent
1dc208233c
commit
8f103aeb71
8 changed files with 136 additions and 40 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue