From e37934c9f2452943ebe7d566408cf6114b6324b1 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Thu, 19 Dec 2024 11:49:49 +0700 Subject: [PATCH] fixing cookie --- src/api/index.ts | 4 ++-- src/views/home.vue | 15 ++++++++------- src/views/sso.vue | 5 ++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index adcd51b..224c1e8 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -17,8 +17,8 @@ export const urlSSO = import.meta.env.VITE_URL_SSO; const config = ref({ development: { // API_URI: "https://localhost:7260/api", - API_URI: "https://bma-ehr.frappet.synology.me/api/v1", - API_SSO: "https://localhost:3001/api/v1", + API_URI: "https://hrms.chin.in.th/api/v1", + API_SSO: "http://localhost:3001/api/v1/sso", URL_ADMIN: urlAdmin, URL_USER: urlUser, URL_MGT: urlMgt, diff --git a/src/views/home.vue b/src/views/home.vue index 369b2b1..1c6d09d 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -48,7 +48,8 @@ const cards = ref([ const token = ref(""); const refreshToken = ref(""); -const fullname = computed(async () => { +const name = ref(""); +async function getName() { const token = await getCookie(cookieTokenName.value); if (token) { const base64Url = token.split(".")[1]; @@ -58,12 +59,11 @@ const fullname = computed(async () => { // ถอดรหัส Base64 const decoded = atob(base64); - const decodedData = JSON.parse(decoded); // ดึงชื่อผู้ใช้ - return decodeURIComponent(escape(decodedData.name)); - } else return ""; -}); + name.value = JSON.parse(decoded).name; + } else name.value = ""; +} async function goPage(sys: string, url: string) { const token = await getCookie(cookieTokenName.value); @@ -144,7 +144,6 @@ async function postSaveLog(type: string, token: any) { headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, - accept: "application/json", }, } ) @@ -157,6 +156,7 @@ async function postSaveLog(type: string, token: any) { } onMounted(async () => { + deleteCookie("BMAHRISMGT_KEYCLOAK_IDENTITY"); deleteCookie("BMAHRISADM_KEYCLOAK_IDENTITY"); deleteCookie("BMAHRISCKI_KEYCLOAK_IDENTITY"); deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY"); @@ -194,6 +194,7 @@ onMounted(async () => { token.value = await getCookie(cookieTokenName.value); refreshToken.value = await getCookie(cookieTokenRefName.value); } + getName(); }); @@ -223,7 +224,7 @@ onMounted(async () => {
- {{ fullname }} + {{ name }}