fixing layout and uid for dev

This commit is contained in:
Warunee Tamkoo 2025-03-13 17:24:09 +07:00
parent a5186c4ea1
commit 3dfc3205bb
4 changed files with 46 additions and 41 deletions

View file

@ -17,7 +17,7 @@ export const urlSSO = import.meta.env.VITE_URL_SSO;
const config = ref<any>({
development: {
// API_URI: "https://localhost:7260/api",
API_URI: "https://hrms.chin.in.th/api/v1",
API_URI: "http://localhost:3001/api/v1",
API_SSO: "http://localhost:3001/api/v1/sso",
URL_ADMIN: urlAdmin,
URL_USER: urlUser,

View file

@ -183,44 +183,49 @@ onMounted(async () => {
deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY");
const uid = route.query.uid?.toString() || getCookie("uid");
const serve = location.hostname == "hrms.bangkok.go.th" ? "sso" : "uat";
await axios
.post(
`${config.API.sso}/kcauth`,
{ uid, serve },
{
headers: {
"Content-Type": "application/json",
},
withCredentials: true, // Include cookies with the request
}
)
.then(async (res: any) => {
if (res.status === 200) {
if (res.data.access_token) {
setCookie(cookieTokenName.value, res.data.access_token, 1);
setCookie(cookieTokenRefName.value, res.data.refresh_token, 1);
token.value = await res.data.access_token;
refreshToken.value = await res.data.refresh_token;
// log
await postSaveLog("เข้าสู่ระบบ", res.data.access_token);
} else if (res.data.isLogin) {
token.value = await getCookie(cookieTokenName.value);
refreshToken.value = await getCookie(cookieTokenRefName.value);
if (uid) {
// token cookie url cookie
await axios
.post(
`${config.API.sso}/kcauth`,
{ uid },
{
headers: {
"Content-Type": "application/json",
},
withCredentials: true, // Include cookies with the request
}
}
})
.catch((err: any) => {
if (location.hostname != "hrms.bangkok.go.th") {
router.push("/sso");
} else {
window.location.href = `${config.API.URL_SSO}`;
}
});
)
.then(async (res: any) => {
if (res.status === 200) {
if (res.data.access_token) {
setCookie(cookieTokenName.value, res.data.access_token, 1);
setCookie(cookieTokenRefName.value, res.data.refresh_token, 1);
setCookie("uid", uid, 1);
getName();
token.value = await res.data.access_token;
refreshToken.value = await res.data.refresh_token;
// log
await postSaveLog("เข้าสู่ระบบ", res.data.access_token);
} else if (res.data.isLogin) {
token.value = await getCookie(cookieTokenName.value);
refreshToken.value = await getCookie(cookieTokenRefName.value);
}
}
})
.catch((err: any) => {
deleteCookie("uid");
if (location.hostname != "hrms.bangkok.go.th") {
router.push("/sso");
} else {
window.location.href = `${config.API.URL_SSO}`;
}
});
//
getName();
}
});
</script>
@ -231,7 +236,7 @@ onMounted(async () => {
</div>
<div class="row justify-center">
<div class="col-md-8 col-sm-12">
<div class="col-md-10 col-sm-12">
<q-toolbar style="padding: 0px">
<div class="row items-center q-py-sm">
<q-img :src="assetSso" style="width: 80px" />

View file

@ -43,8 +43,8 @@ async function onSubmit() {
}
)
.then(async (res) => {
if (res.data === "OK") {
await setCookie("uid", username.value, 1);
if (res.data.uid) {
await setCookie("uid", res.data.uid, 1);
router.push("/");
}
})

View file

@ -26,7 +26,7 @@ export default defineConfig({
},
includeAssets: ['icons/safari-pinned-tab.svg'],
manifest: {
name: 'BMA-Checkin',
name: 'HRMS-Checkin',
short_name: 'EHR Checkin',
theme_color: '#ffffff',
},