fix ==> redirectUrl
This commit is contained in:
parent
d6249b2606
commit
37e3c65ff3
1 changed files with 35 additions and 5 deletions
|
|
@ -1,6 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { deleteCookie, getCookie, setCookie } from "@/plugins/cookie";
|
||||
import router from "@/router";
|
||||
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import axios from "axios";
|
||||
|
|
@ -15,6 +18,7 @@ import screen4 from "@/assets/screen4.png";
|
|||
import type { DateCards } from "@/interface/index/Main";
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
|
||||
const cookieTokenName = ref<string>("BMAHRIS_KEYCLOAK_IDENTITY");
|
||||
const cookieTokenRefName = ref<string>("BMAHRIS_KEYCLOAK_REFRESH");
|
||||
|
|
@ -67,6 +71,7 @@ async function getName() {
|
|||
|
||||
async function goPage(sys: string, url: string) {
|
||||
const token = await getCookie(cookieTokenName.value);
|
||||
const redirectUrl = (route.query.redirectUrl as string) ?? "";
|
||||
|
||||
if (token) {
|
||||
// แยกส่วน Payload ของ JWT (ส่วนที่ 2)
|
||||
|
|
@ -98,7 +103,11 @@ async function goPage(sys: string, url: string) {
|
|||
JSON.parse(decoded).realm_access.roles.includes(role)
|
||||
)
|
||||
) {
|
||||
window.location.href = `${url}/auth?token=${token}&accessToken=${refreshToken.value}`;
|
||||
if (redirectUrl) {
|
||||
window.location.href = `${url}/auth?token=${token}&accessToken=${refreshToken.value}&redirectUrl=${redirectUrl}`;
|
||||
} else {
|
||||
window.location.href = `${url}/auth?token=${token}&accessToken=${refreshToken.value}`;
|
||||
}
|
||||
} else {
|
||||
// alert("คุณไม่มีสิทธิ์เข้าใช้งานระบบนี้");
|
||||
$q.dialog({
|
||||
|
|
@ -156,10 +165,15 @@ async function postSaveLog(type: string, token: any) {
|
|||
}
|
||||
|
||||
onMounted(async () => {
|
||||
deleteCookie("BMAHRISMGT_KEYCLOAK_IDENTITY");
|
||||
deleteCookie("BMAHRISADM_KEYCLOAK_IDENTITY");
|
||||
deleteCookie("BMAHRISCKI_KEYCLOAK_IDENTITY");
|
||||
deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY");
|
||||
// deleteCookie("BMAHRISMGT_KEYCLOAK_IDENTITY");
|
||||
// deleteCookie("BMAHRISADM_KEYCLOAK_IDENTITY");
|
||||
// deleteCookie("BMAHRISCKI_KEYCLOAK_IDENTITY");
|
||||
// deleteCookie("BMAHRISUSER_KEYCLOAK_IDENTITY");
|
||||
|
||||
token.value = await getCookie(cookieTokenName.value);
|
||||
refreshToken.value = await getCookie(cookieTokenRefName.value);
|
||||
|
||||
if (!token.value || !refreshToken.value) router.push("/sso");
|
||||
|
||||
await axios
|
||||
.post(
|
||||
|
|
@ -187,6 +201,22 @@ onMounted(async () => {
|
|||
token.value = await getCookie(cookieTokenName.value);
|
||||
refreshToken.value = await getCookie(cookieTokenRefName.value);
|
||||
}
|
||||
|
||||
const systemkey = route.query.system as string;
|
||||
if (systemkey) {
|
||||
goPage(
|
||||
systemkey,
|
||||
systemkey === "user"
|
||||
? urlUser
|
||||
: systemkey === "checkin"
|
||||
? urlCheckin
|
||||
: systemkey === "mgt"
|
||||
? urlMgt
|
||||
: systemkey === "admin"
|
||||
? urlAdmin
|
||||
: ""
|
||||
);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue