fixing cookie

This commit is contained in:
Warunee Tamkoo 2024-12-19 11:49:49 +07:00
parent 71d85cf2bb
commit e37934c9f2
3 changed files with 12 additions and 12 deletions

View file

@ -17,8 +17,8 @@ export const urlSSO = import.meta.env.VITE_URL_SSO;
const config = ref<any>({
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,

View file

@ -48,7 +48,8 @@ const cards = ref<DateCards[]>([
const token = ref<any>("");
const refreshToken = ref<any>("");
const fullname = computed(async () => {
const name = ref<string>("");
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();
});
</script>
@ -223,7 +224,7 @@ onMounted(async () => {
<q-space />
<div class="row items-center q-col-gutter-md">
<div class="text-white">
{{ fullname }}
{{ name }}
</div>
<div>
<q-btn

View file

@ -1,14 +1,14 @@
<!-- authen with keycloak client -->
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
// import { useQuasar } from "quasar";
import axios from "axios";
import config from "@/app.config";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
// const $q = useQuasar();
const router = useRouter();
const mixin = useCounterMixin();
@ -45,7 +45,6 @@ async function onSubmit() {
if (res.data === "OK") {
router.push("/");
}
console.log("res===>", res);
})
.catch((err) => {
msgError.value = "ชื่อผู้ใช้งานหรือรหัสผ่านไม่ถูกต้อง";