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 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}`;