diff --git a/src/router/index.ts b/src/router/index.ts index 892c18743..1e7576923 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -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();