This commit is contained in:
Warunee Tamkoo 2025-02-11 11:37:43 +07:00
parent ad0973249e
commit 8979672717
2 changed files with 9 additions and 5 deletions

View file

@ -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",

View file

@ -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("/");
}
})