session
This commit is contained in:
@@ -3,6 +3,11 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
let TOKEN_KEY = 'kb-user-center-token'
|
let TOKEN_KEY = 'kb-user-center-token'
|
||||||
|
|
||||||
|
let domain = location.hostname
|
||||||
|
if (domain.indexOf('kuboard.cn') >= 0) {
|
||||||
|
domain = 'kuboard.cn'
|
||||||
|
}
|
||||||
|
|
||||||
window.KbUcloginStatus = {
|
window.KbUcloginStatus = {
|
||||||
status: Cookies.get(TOKEN_KEY) !== null && Cookies.get(TOKEN_KEY) !== undefined,
|
status: Cookies.get(TOKEN_KEY) !== null && Cookies.get(TOKEN_KEY) !== undefined,
|
||||||
user: undefined
|
user: undefined
|
||||||
@@ -11,13 +16,13 @@ window.KbUcloginStatus = {
|
|||||||
Vue.prototype.$login = function (token) {
|
Vue.prototype.$login = function (token) {
|
||||||
// axios.defaults.headers.common['Authorization'] = token;
|
// axios.defaults.headers.common['Authorization'] = token;
|
||||||
// localStorage.setItem(TOKEN_KEY, token)
|
// localStorage.setItem(TOKEN_KEY, token)
|
||||||
Cookies.set(TOKEN_KEY, token, { path: '/' })
|
Cookies.set(TOKEN_KEY, token, { domain: domain, expires: 7, path: '/' })
|
||||||
window.KbUcloginStatus.status = true
|
window.KbUcloginStatus.status = true
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$logout = function () {
|
Vue.prototype.$logout = function () {
|
||||||
window.KbUcloginStatus.status = false
|
window.KbUcloginStatus.status = false
|
||||||
// localStorage.removeItem(TOKEN_KEY)
|
// localStorage.removeItem(TOKEN_KEY)
|
||||||
Cookies.remove(TOKEN_KEY, { path: '/' })
|
Cookies.remove(TOKEN_KEY, { domain: domain, expires: 7, path: '/' })
|
||||||
// delete (axios.defaults.headers.common['Authorization'])
|
// delete (axios.defaults.headers.common['Authorization'])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user