fixing
This commit is contained in:
parent
8979672717
commit
a5186c4ea1
1 changed files with 23 additions and 8 deletions
|
|
@ -28,6 +28,7 @@ const urlUser = config.API.URL_USER;
|
||||||
const urlMgt = config.API.URL_MGT;
|
const urlMgt = config.API.URL_MGT;
|
||||||
const urlCheckin = config.API.URL_CHECKIN;
|
const urlCheckin = config.API.URL_CHECKIN;
|
||||||
|
|
||||||
|
// รายการระบบที่สามารถเข้าใช้งานได้
|
||||||
const cards = ref<DateCards[]>([
|
const cards = ref<DateCards[]>([
|
||||||
{
|
{
|
||||||
label: "ระบบบริการเจ้าของข้อมูล",
|
label: "ระบบบริการเจ้าของข้อมูล",
|
||||||
|
|
@ -51,9 +52,13 @@ const cards = ref<DateCards[]>([
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const token = ref<any>("");
|
const token = ref<any>(""); // สำหรับเก็บ token ที่ได้จาก cookie
|
||||||
const refreshToken = ref<any>("");
|
const refreshToken = ref<any>(""); // สำหรับเก็บ refresh token ที่ได้จาก cookie
|
||||||
const name = ref<string>("");
|
const name = ref<string>(""); // สำหรับเก็บชื่อผู้ใช้
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันสำหรับดึงชื่อผู้ใช้
|
||||||
|
*/
|
||||||
async function getName() {
|
async function getName() {
|
||||||
const token = await getCookie(cookieTokenName.value);
|
const token = await getCookie(cookieTokenName.value);
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|
@ -70,6 +75,11 @@ async function getName() {
|
||||||
} else name.value = "";
|
} else name.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับตรวจสอบสิทธิ์ และเปลี่ยนหน้าไปยัง url ของระบบที่ต้องการ
|
||||||
|
* @param sys ระบบที่ต้องการเข้าถึง
|
||||||
|
* @param url ลิงค์ของระบบที่ต้องการเข้าถึง
|
||||||
|
*/
|
||||||
async function goPage(sys: string, url: string) {
|
async function goPage(sys: string, url: string) {
|
||||||
const token = await getCookie(cookieTokenName.value);
|
const token = await getCookie(cookieTokenName.value);
|
||||||
|
|
||||||
|
|
@ -94,9 +104,6 @@ async function goPage(sys: string, url: string) {
|
||||||
requiredRole = ["ADMIN", "SUPER_ADMIN"];
|
requiredRole = ["ADMIN", "SUPER_ADMIN"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log("requiredRole===>", requiredRole);
|
|
||||||
// console.log("decoded===>", JSON.parse(decoded).realm_access.roles);
|
|
||||||
|
|
||||||
// ตรวจสอบว่า payload.role มีค่าหรือไม่ และว่ามี role ที่ต้องการหรือไม่
|
// ตรวจสอบว่า payload.role มีค่าหรือไม่ และว่ามี role ที่ต้องการหรือไม่
|
||||||
if (
|
if (
|
||||||
requiredRole.some((role) =>
|
requiredRole.some((role) =>
|
||||||
|
|
@ -120,6 +127,9 @@ async function goPage(sys: string, url: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับออกจากระบบ
|
||||||
|
*/
|
||||||
async function logout() {
|
async function logout() {
|
||||||
$q.dialog({
|
$q.dialog({
|
||||||
component: CustomComponent,
|
component: CustomComponent,
|
||||||
|
|
@ -141,6 +151,11 @@ async function logout() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชั่นสำหรับบันทึก log เข้าระบบ
|
||||||
|
* @param type
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
async function postSaveLog(type: string, token: any) {
|
async function postSaveLog(type: string, token: any) {
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
|
|
@ -168,7 +183,7 @@ 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 = route.query.uid ? "sso" : "uat";
|
const serve = location.hostname == "hrms.bangkok.go.th" ? "sso" : "uat";
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
`${config.API.sso}/kcauth`,
|
`${config.API.sso}/kcauth`,
|
||||||
|
|
@ -198,7 +213,7 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
if (location.hostname == "hrms.chin.in.th") {
|
if (location.hostname != "hrms.bangkok.go.th") {
|
||||||
router.push("/sso");
|
router.push("/sso");
|
||||||
} else {
|
} else {
|
||||||
window.location.href = `${config.API.URL_SSO}`;
|
window.location.href = `${config.API.URL_SSO}`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue