fixing layout and uid for dev
This commit is contained in:
parent
a5186c4ea1
commit
3dfc3205bb
4 changed files with 46 additions and 41 deletions
|
|
@ -17,7 +17,7 @@ export const urlSSO = import.meta.env.VITE_URL_SSO;
|
||||||
const config = ref<any>({
|
const config = ref<any>({
|
||||||
development: {
|
development: {
|
||||||
// API_URI: "https://localhost:7260/api",
|
// 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",
|
API_SSO: "http://localhost:3001/api/v1/sso",
|
||||||
URL_ADMIN: urlAdmin,
|
URL_ADMIN: urlAdmin,
|
||||||
URL_USER: urlUser,
|
URL_USER: urlUser,
|
||||||
|
|
|
||||||
|
|
@ -183,44 +183,49 @@ onMounted(async () => {
|
||||||
deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY");
|
deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY");
|
||||||
|
|
||||||
const uid = route.query.uid?.toString() || getCookie("uid");
|
const uid = route.query.uid?.toString() || getCookie("uid");
|
||||||
const serve = location.hostname == "hrms.bangkok.go.th" ? "sso" : "uat";
|
if (uid) {
|
||||||
await axios
|
// ยิงไปตรวจสอบ token ที่ได้จาก cookie หรือจาก url แล้วเก็บไว้ใน cookie
|
||||||
.post(
|
await axios
|
||||||
`${config.API.sso}/kcauth`,
|
.post(
|
||||||
{ uid, serve },
|
`${config.API.sso}/kcauth`,
|
||||||
{
|
{ uid },
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/json",
|
headers: {
|
||||||
},
|
"Content-Type": "application/json",
|
||||||
withCredentials: true, // Include cookies with the request
|
},
|
||||||
}
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
})
|
.then(async (res: any) => {
|
||||||
.catch((err: any) => {
|
if (res.status === 200) {
|
||||||
if (location.hostname != "hrms.bangkok.go.th") {
|
if (res.data.access_token) {
|
||||||
router.push("/sso");
|
setCookie(cookieTokenName.value, res.data.access_token, 1);
|
||||||
} else {
|
setCookie(cookieTokenRefName.value, res.data.refresh_token, 1);
|
||||||
window.location.href = `${config.API.URL_SSO}`;
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
@ -231,7 +236,7 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row justify-center">
|
<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">
|
<q-toolbar style="padding: 0px">
|
||||||
<div class="row items-center q-py-sm">
|
<div class="row items-center q-py-sm">
|
||||||
<q-img :src="assetSso" style="width: 80px" />
|
<q-img :src="assetSso" style="width: 80px" />
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ async function onSubmit() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.data === "OK") {
|
if (res.data.uid) {
|
||||||
await setCookie("uid", username.value, 1);
|
await setCookie("uid", res.data.uid, 1);
|
||||||
router.push("/");
|
router.push("/");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
includeAssets: ['icons/safari-pinned-tab.svg'],
|
includeAssets: ['icons/safari-pinned-tab.svg'],
|
||||||
manifest: {
|
manifest: {
|
||||||
name: 'BMA-Checkin',
|
name: 'HRMS-Checkin',
|
||||||
short_name: 'EHR Checkin',
|
short_name: 'EHR Checkin',
|
||||||
theme_color: '#ffffff',
|
theme_color: '#ffffff',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue