updated authen
This commit is contained in:
parent
9ec6a7696a
commit
c1f0ac7939
5 changed files with 39 additions and 28 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
|
|
@ -8,7 +8,7 @@ function setCookie(name: string, value: any, days: number) {
|
|||
let expires = ''
|
||||
if (days) {
|
||||
const date = new Date()
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 55 * 1000)
|
||||
expires = '; expires=' + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<!-- authen with keycloak client -->
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import axios from 'axios'
|
||||
import { keycloakConfig } from '@/plugins/keycloak'
|
||||
import keycloak, { keycloakConfig } from '@/plugins/keycloak'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
|
|
@ -17,7 +17,7 @@ function setCookie(name: string, value: any, days: number) {
|
|||
let expires = ''
|
||||
if (days) {
|
||||
const date = new Date()
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 55 * 1000)
|
||||
expires = '; expires=' + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/'
|
||||
|
|
@ -31,10 +31,6 @@ async function onSubmit() {
|
|||
formdata.append('client_id', keycloakConfig.clientId)
|
||||
formdata.append('client_secret', keycloakConfig.clientSecret)
|
||||
formdata.append('grant_type', 'password')
|
||||
formdata.append(
|
||||
'requested_token_type',
|
||||
'urn:ietf:params:oauth:token-type:refresh_token'
|
||||
)
|
||||
formdata.append('username', username.value)
|
||||
formdata.append('password', password.value)
|
||||
|
||||
|
|
@ -68,6 +64,14 @@ async function onSubmit() {
|
|||
// router.push('/')
|
||||
// }
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (keycloak.authenticated) {
|
||||
console.log('authenticated', keycloak.authenticated)
|
||||
|
||||
router.push('/')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue