fix cookie
This commit is contained in:
parent
1774cf1991
commit
37372666a4
2 changed files with 21 additions and 3 deletions
|
|
@ -16,6 +16,11 @@ async function setAuthen(r: AuthResponse) {
|
|||
window.location.href = '/'
|
||||
}
|
||||
|
||||
async function setAuthenCheckin(r: AuthResponse) {
|
||||
await setCookieCheckin(ACCESS_TOKEN, r.access_token, r.expires_in)
|
||||
window.location.href = '/'
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await deleteCookie(ACCESS_TOKEN)
|
||||
window.location.href = key_C_Config.url_Logout
|
||||
|
|
@ -31,6 +36,19 @@ function setCookie(name: string, value: any, time: number) {
|
|||
const date = new Date()
|
||||
date.setTime(date.getTime() + time * 1000)
|
||||
// date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
date.setMonth(date.getMonth() + 6)
|
||||
expires = '; expires=' + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/'
|
||||
}
|
||||
|
||||
function setCookieCheckin(name: string, value: any, time: number) {
|
||||
let expires = ''
|
||||
if (time) {
|
||||
const date = new Date()
|
||||
|
||||
// date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
date.setMonth(date.getMonth() + 6)
|
||||
expires = '; expires=' + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/'
|
||||
|
|
@ -71,4 +89,4 @@ async function tokenParsed() {
|
|||
return JSON.parse(jsonPayload)
|
||||
}
|
||||
|
||||
export { getToken, authenticated, logout, setAuthen, tokenParsed }
|
||||
export { getToken, authenticated, logout, setAuthen, tokenParsed ,setAuthenCheckin}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import axios from 'axios'
|
|||
import { useRouter } from 'vue-router'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { setAuthen, authenticated } from '@/plugins/auth'
|
||||
import { setAuthen, authenticated, setAuthenCheckin } from '@/plugins/auth'
|
||||
import CustomComponent from '@/components/CustomDialog.vue'
|
||||
import env from '@/api/index'
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ async function onSubmit() {
|
|||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
setAuthen(res.data.result)
|
||||
setAuthenCheckin(res.data.result)
|
||||
})
|
||||
.catch((err) => {
|
||||
$q.dialog({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue