remove keycloak use cookie auth

This commit is contained in:
Warunee Tamkoo 2024-08-28 15:29:09 +07:00
parent 035db71697
commit 5a5e37c12d
27 changed files with 501 additions and 440 deletions

View file

@ -29,7 +29,7 @@ import ModuleSupport from "@/modules/00_support/router";
import ModuleActing from "@/modules/17_acting/router";
// TODO: ใช้หรือไม่?
import keycloak, { kcLogout } from "@/plugins/keycloak";
import { authenticated } from "@/plugins/auth";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@ -86,7 +86,7 @@ const router = createRouter({
component: Error404NotFound,
},
// authen with keycloak client
// authen with client
{
path: "/login",
name: "loginMain",
@ -114,11 +114,12 @@ const router = createRouter({
},
});
// authen with keycloak client
router.beforeEach((to, from, next) => {
// authen with client
router.beforeEach(async (to, from, next) => {
if (to.meta.Auth) {
if (keycloak.authenticated === undefined) {
kcLogout();
const checkAuthen = await authenticated();
if (!checkAuthen && to.meta.Auth) {
router.push({ name: "loginMain" });
} else {
next();
}