fixing check token
This commit is contained in:
parent
04da1988b0
commit
00cb0c6f23
7 changed files with 83 additions and 66 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import axios from 'axios'
|
||||
import keycloak, { keycloakConfig } from '@/plugins/keycloak'
|
||||
import keycloak, { kcAuthen, keycloakConfig } from '@/plugins/keycloak'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
|
|
@ -13,16 +13,6 @@ const $q = useQuasar() //ใช้ noti quasar
|
|||
|
||||
const { showLoader, hideLoader, messageError } = mixin
|
||||
|
||||
function setCookie(name: string, value: any, days: number) {
|
||||
let expires = ''
|
||||
if (days) {
|
||||
const date = new Date()
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 55 * 1000)
|
||||
expires = '; expires=' + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/'
|
||||
}
|
||||
|
||||
const username = ref<string>('')
|
||||
const password = ref<string>('')
|
||||
async function onSubmit() {
|
||||
|
|
@ -45,9 +35,7 @@ async function onSubmit() {
|
|||
}
|
||||
)
|
||||
.then(async (res) => {
|
||||
await setCookie('BMAHRIS_KEYCLOAK_IDENTITY', res.data.access_token, 1)
|
||||
await setCookie('BMAHRIS_KEYCLOAK_REFRESH', res.data.refresh_token, 1)
|
||||
window.location.href = '/'
|
||||
kcAuthen(res.data.access_token, res.data.refresh_token)
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err, 'ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง')
|
||||
|
|
@ -55,14 +43,6 @@ async function onSubmit() {
|
|||
.finally(() => {
|
||||
hideLoader()
|
||||
})
|
||||
|
||||
// if (response.status !== 200) {
|
||||
// messageError($q, err)
|
||||
// } else {
|
||||
// await setCookie('BMAHRIS_KEYCLOAK_IDENTITY', response.data.access_token, 1)
|
||||
// await setCookie('BMAHRIS_KEYCLOAK_REFRESH', response.data.refresh_token, 1)
|
||||
// router.push('/')
|
||||
// }
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue