fixing check token auth

This commit is contained in:
Warunee Tamkoo 2024-08-16 17:00:33 +07:00
parent 46d561b43b
commit a5fbf5c880
3 changed files with 36 additions and 16 deletions

View file

@ -1,6 +1,7 @@
import { defineStore } from 'pinia'
import CustomComponent from '@/components/CustomDialog.vue'
import { Loading, QSpinnerCube } from 'quasar'
import { kcLogout } from '@/plugins/keycloak'
export const useCounterMixin = defineStore('mixin', () => {
function date2Thai(srcDate: Date, isFullMonth = false, isTime = false) {
@ -143,6 +144,12 @@ export const useCounterMixin = defineStore('mixin', () => {
color: 'red',
onlycancel: true,
},
}).onCancel(async () => {
showLoader()
await kcLogout()
setTimeout(() => {
hideLoader()
}, 1000)
})
} else {
const message = e.response.data.result ?? e.response.data.message
@ -169,6 +176,12 @@ export const useCounterMixin = defineStore('mixin', () => {
color: 'red',
onlycancel: true,
},
}).onCancel(async () => {
showLoader()
await kcLogout()
setTimeout(() => {
hideLoader()
}, 1000)
})
} else {
//invalid_token
@ -181,6 +194,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) {