fixing check token auth
This commit is contained in:
parent
46d561b43b
commit
a5fbf5c880
3 changed files with 36 additions and 16 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import Axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
import Axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
||||||
import keycloak, { kcLogout } from './keycloak'
|
import keycloak from './keycloak'
|
||||||
|
|
||||||
const http = Axios.create({
|
const http = Axios.create({
|
||||||
timeout: 1000000000, // เพิ่มค่า timeout
|
timeout: 1000000000, // เพิ่มค่า timeout
|
||||||
|
|
@ -31,8 +31,6 @@ http.interceptors.response.use(
|
||||||
// eslint-disable-next-line no-prototype-builtins
|
// eslint-disable-next-line no-prototype-builtins
|
||||||
if (error.hasOwnProperty('response')) {
|
if (error.hasOwnProperty('response')) {
|
||||||
if (error.response.status === 401 || error.response.status === 403) {
|
if (error.response.status === 401 || error.response.status === 403) {
|
||||||
kcLogout()
|
|
||||||
|
|
||||||
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
|
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
|
||||||
// Store.commit("REMOVE_ACCESS_TOKEN")
|
// Store.commit("REMOVE_ACCESS_TOKEN")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import CustomComponent from '@/components/CustomDialog.vue'
|
import CustomComponent from '@/components/CustomDialog.vue'
|
||||||
import { Loading, QSpinnerCube } from 'quasar'
|
import { Loading, QSpinnerCube } from 'quasar'
|
||||||
|
import { kcLogout } from '@/plugins/keycloak'
|
||||||
|
|
||||||
export const useCounterMixin = defineStore('mixin', () => {
|
export const useCounterMixin = defineStore('mixin', () => {
|
||||||
function date2Thai(srcDate: Date, isFullMonth = false, isTime = false) {
|
function date2Thai(srcDate: Date, isFullMonth = false, isTime = false) {
|
||||||
|
|
@ -143,6 +144,12 @@ export const useCounterMixin = defineStore('mixin', () => {
|
||||||
color: 'red',
|
color: 'red',
|
||||||
onlycancel: true,
|
onlycancel: true,
|
||||||
},
|
},
|
||||||
|
}).onCancel(async () => {
|
||||||
|
showLoader()
|
||||||
|
await kcLogout()
|
||||||
|
setTimeout(() => {
|
||||||
|
hideLoader()
|
||||||
|
}, 1000)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const message = e.response.data.result ?? e.response.data.message
|
const message = e.response.data.result ?? e.response.data.message
|
||||||
|
|
@ -169,6 +176,12 @@ export const useCounterMixin = defineStore('mixin', () => {
|
||||||
color: 'red',
|
color: 'red',
|
||||||
onlycancel: true,
|
onlycancel: true,
|
||||||
},
|
},
|
||||||
|
}).onCancel(async () => {
|
||||||
|
showLoader()
|
||||||
|
await kcLogout()
|
||||||
|
setTimeout(() => {
|
||||||
|
hideLoader()
|
||||||
|
}, 1000)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
//invalid_token
|
//invalid_token
|
||||||
|
|
@ -181,6 +194,12 @@ export const useCounterMixin = defineStore('mixin', () => {
|
||||||
color: 'red',
|
color: 'red',
|
||||||
onlycancel: true,
|
onlycancel: true,
|
||||||
},
|
},
|
||||||
|
}).onCancel(async () => {
|
||||||
|
showLoader()
|
||||||
|
await kcLogout()
|
||||||
|
setTimeout(() => {
|
||||||
|
hideLoader()
|
||||||
|
}, 1000)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (e.response.data.successful === false) {
|
} else if (e.response.data.successful === false) {
|
||||||
|
|
|
||||||
|
|
@ -45,20 +45,23 @@ async function fetchNotifications(index: number, type: string) {
|
||||||
if (type === 'DEL') {
|
if (type === 'DEL') {
|
||||||
notiList.value = []
|
notiList.value = []
|
||||||
}
|
}
|
||||||
response.map((e: Noti) => {
|
|
||||||
list.push({
|
if (response.length === 0) {
|
||||||
id: e.id,
|
response.map((e: Noti) => {
|
||||||
sender:
|
list.push({
|
||||||
e.createdFullName == '' || e.createdFullName == null
|
id: e.id,
|
||||||
? 'เจ้าหน้าที่'[0]
|
sender:
|
||||||
: e.createdFullName[0],
|
e.createdFullName == '' || e.createdFullName == null
|
||||||
body: e.body ?? '',
|
? 'เจ้าหน้าที่'[0]
|
||||||
timereceive: e.receiveDate,
|
: e.createdFullName[0],
|
||||||
isOpen: e.isOpen,
|
body: e.body ?? '',
|
||||||
|
timereceive: e.receiveDate,
|
||||||
|
isOpen: e.isOpen,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
notiList.value.push(...list)
|
||||||
notiList.value.push(...list)
|
statusLoad.value = totalNotiList.value === 0 ? true : false
|
||||||
statusLoad.value = totalNotiList.value === 0 ? true : false
|
}
|
||||||
})
|
})
|
||||||
// .catch((err) => {
|
// .catch((err) => {
|
||||||
// messageError($q, err)
|
// messageError($q, err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue