fixing check token auth
This commit is contained in:
parent
e1acb72512
commit
f4db48d0bf
2 changed files with 21 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import Axios, { type AxiosRequestConfig, type AxiosResponse } from "axios";
|
||||
import keycloak, { kcLogout } from "./keycloak";
|
||||
import keycloak from "./keycloak";
|
||||
|
||||
const http = Axios.create({
|
||||
timeout: 1000000000, // เพิ่มค่า timeout
|
||||
|
|
@ -33,7 +33,7 @@ http.interceptors.response.use(
|
|||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (error.hasOwnProperty("response")) {
|
||||
if (error.response.status === 401 || error.response.status === 403) {
|
||||
kcLogout();
|
||||
// kcLogout();
|
||||
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
|
||||
// Store.commit("REMOVE_ACCESS_TOKEN")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import "moment/dist/locale/th";
|
|||
import moment from "moment";
|
||||
import CustomComponent from "@/components/CustomDialog.vue";
|
||||
import { Loading, QSpinnerCube } from "quasar";
|
||||
import { kcLogout } from "@/plugins/keycloak";
|
||||
|
||||
moment.locale("th");
|
||||
|
||||
|
|
@ -346,7 +347,6 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
}
|
||||
|
||||
const messageError = (q: any, e: any = "", msg: string = "") => {
|
||||
// q.dialog.hide();
|
||||
if (e.response !== undefined) {
|
||||
if (e.response.data.status !== undefined) {
|
||||
if (e.response.data.status == 401) {
|
||||
|
|
@ -360,6 +360,12 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
color: "red",
|
||||
onlycancel: true,
|
||||
},
|
||||
}).onCancel(async () => {
|
||||
showLoader();
|
||||
await kcLogout();
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 1000);
|
||||
});
|
||||
} else if (e.response.data.status == 400 && e.response.data.title) {
|
||||
//validation errors
|
||||
|
|
@ -398,6 +404,12 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
color: "red",
|
||||
onlycancel: true,
|
||||
},
|
||||
}).onCancel(async () => {
|
||||
showLoader();
|
||||
await kcLogout();
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 1000);
|
||||
});
|
||||
} else {
|
||||
//invalid_token
|
||||
|
|
@ -410,6 +422,12 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
color: "red",
|
||||
onlycancel: true,
|
||||
},
|
||||
}).onCancel(async () => {
|
||||
showLoader();
|
||||
await kcLogout();
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
} else if (e.response.data.successful === false) {
|
||||
|
|
@ -437,8 +455,6 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
console.error("err===>", e); // ***
|
||||
|
||||
if (e.message && e.message !== "R is not a function") {
|
||||
q.dialog({
|
||||
component: CustomComponent,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue