This commit is contained in:
Warunee Tamkoo 2025-02-21 15:26:09 +07:00
parent 8979672717
commit a5186c4ea1

View file

@ -28,6 +28,7 @@ const urlUser = config.API.URL_USER;
const urlMgt = config.API.URL_MGT;
const urlCheckin = config.API.URL_CHECKIN;
//
const cards = ref<DateCards[]>([
{
label: "ระบบบริการเจ้าของข้อมูล",
@ -51,9 +52,13 @@ const cards = ref<DateCards[]>([
},
]);
const token = ref<any>("");
const refreshToken = ref<any>("");
const name = ref<string>("");
const token = ref<any>(""); // token cookie
const refreshToken = ref<any>(""); // refresh token cookie
const name = ref<string>(""); //
/**
* งกนสำหรบดงชอผใช
*/
async function getName() {
const token = await getCookie(cookieTokenName.value);
if (token) {
@ -70,6 +75,11 @@ async function getName() {
} else name.value = "";
}
/**
* งกนสำหรบตรวจสอบสทธ และเปลยนหนาไปย url ของระบบทองการ
* @param sys ระบบทองการเขาถ
* @param url งคของระบบทองการเขาถ
*/
async function goPage(sys: string, url: string) {
const token = await getCookie(cookieTokenName.value);
@ -94,9 +104,6 @@ async function goPage(sys: string, url: string) {
requiredRole = ["ADMIN", "SUPER_ADMIN"];
}
// console.log("requiredRole===>", requiredRole);
// console.log("decoded===>", JSON.parse(decoded).realm_access.roles);
// payload.role role
if (
requiredRole.some((role) =>
@ -120,6 +127,9 @@ async function goPage(sys: string, url: string) {
}
}
/**
* งกนสำหรบออกจากระบบ
*/
async function logout() {
$q.dialog({
component: CustomComponent,
@ -141,6 +151,11 @@ async function logout() {
});
}
/**
* งกนสำหรบบนท log เขาระบบ
* @param type
* @param token
*/
async function postSaveLog(type: string, token: any) {
await axios
.post(
@ -168,7 +183,7 @@ onMounted(async () => {
deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY");
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
.post(
`${config.API.sso}/kcauth`,
@ -198,7 +213,7 @@ onMounted(async () => {
}
})
.catch((err: any) => {
if (location.hostname == "hrms.chin.in.th") {
if (location.hostname != "hrms.bangkok.go.th") {
router.push("/sso");
} else {
window.location.href = `${config.API.URL_SSO}`;