update auth
This commit is contained in:
parent
abeb6ca085
commit
3c36acbba1
10 changed files with 223 additions and 161 deletions
|
|
@ -11,7 +11,7 @@ import ModuleLogs from "@/modules/03_logs/router";
|
|||
import ModuleSystem from "@/modules/04_system/router";
|
||||
|
||||
// TODO: ใช้หรือไม่?
|
||||
import keycloak, { kcLogout } from "@/plugins/keycloak";
|
||||
import { authenticated, logout } from "@/plugins/auth";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
|
@ -76,10 +76,11 @@ const router = createRouter({
|
|||
});
|
||||
|
||||
// authen with keycloak client
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.meta.Auth) {
|
||||
if (keycloak.authenticated === undefined && to.meta.Auth) {
|
||||
kcLogout();
|
||||
const checkAuthen = await authenticated();
|
||||
if (!checkAuthen && to.meta.Auth) {
|
||||
logout();
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue