From 89796727172d8417b98d43d9cbd885a9b04a1ca8 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Tue, 11 Feb 2025 11:37:43 +0700 Subject: [PATCH] fixing --- src/views/home.vue | 10 ++++++---- src/views/sso.vue | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/views/home.vue b/src/views/home.vue index 3546595..0b90c08 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -134,6 +134,7 @@ async function logout() { }).onOk(async () => { await deleteCookie(cookieTokenName.value); await deleteCookie(cookieTokenRefName.value); + await deleteCookie("uid"); // ยิง logout เข้าระบบ await postSaveLog("ออกจากระบบ", token.value); window.location.href = `${config.API.URL_SSO}`; @@ -152,8 +153,8 @@ async function postSaveLog(type: string, token: any) { }, } ) - .then((res) => { - console.log("res:", res.data); + .then(async (res) => { + console.log("res:", res); }) .catch((err) => { console.error("Error:", err); @@ -166,11 +167,12 @@ onMounted(async () => { deleteCookie("BMAHRISCKI_KEYCLOAK_IDENTITY"); deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY"); - const uid = route.query.uid?.toString() || ""; + const uid = route.query.uid?.toString() || getCookie("uid"); + const serve = route.query.uid ? "sso" : "uat"; await axios .post( `${config.API.sso}/kcauth`, - { uid }, + { uid, serve }, { headers: { "Content-Type": "application/json", diff --git a/src/views/sso.vue b/src/views/sso.vue index c3d5f66..81bcc6e 100644 --- a/src/views/sso.vue +++ b/src/views/sso.vue @@ -7,6 +7,7 @@ import config from "@/app.config"; import { useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; +import { setCookie } from "@/plugins/cookie"; // const $q = useQuasar(); const router = useRouter(); @@ -41,8 +42,9 @@ async function onSubmit() { withCredentials: true, // Include cookies with the request } ) - .then((res) => { + .then(async (res) => { if (res.data === "OK") { + await setCookie("uid", username.value, 1); router.push("/"); } })