check cookie redirect to sso

This commit is contained in:
Warunee Tamkoo 2024-12-20 22:36:41 +07:00
parent 3d85971eee
commit dbf6fe0123

View file

@ -27,7 +27,7 @@ import ModuleCommand from "@/modules/18_command/router";
import ModulePositionCondition from "@/modules/19_condition/router";
// TODO: ใช้หรือไม่?
import { authenticated } from "@/plugins/auth";
import { authenticated, logout } from "@/plugins/auth";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@ -117,8 +117,10 @@ const router = createRouter({
router.beforeEach(async (to, from, next) => {
if (to.meta.Auth) {
const checkAuthen = await authenticated();
console.log("checkAuthen", checkAuthen);
if (!checkAuthen && to.meta.Auth) {
router.push({ name: "loginMain" });
logout();
}
}
next();