forked from github/dataease
Merge pull request #614 from dataease/pr@dev@fix_外部链接token机制
fix: 外部链接token存储使用vuex不实用cookie
This commit is contained in:
commit
48f6889fe5
@ -219,7 +219,9 @@ export default {
|
||||
|
||||
// 增加判断 仪表板公共连接中使用viewInfo 正常使用viewData
|
||||
let method = viewData
|
||||
if (!getToken() && getLinkToken()) {
|
||||
const token = this.$store.getters.token || getToken()
|
||||
const linkToken = this.$store.getters.linkToken || getLinkToken()
|
||||
if (!token && linkToken) {
|
||||
method = viewInfo
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ const getters = {
|
||||
size: state => state.app.size,
|
||||
device: state => state.app.device,
|
||||
token: state => state.user.token,
|
||||
linkToken: state => state.user.linkToken,
|
||||
avatar: state => state.user.avatar,
|
||||
name: state => state.user.name,
|
||||
introduction: state => state.user.introduction,
|
||||
|
@ -18,7 +18,8 @@ const getDefaultState = () => {
|
||||
// 当前用户拥有哪些资源权限
|
||||
permissions: [],
|
||||
language: getLanguage(),
|
||||
uiInfo: null
|
||||
uiInfo: null,
|
||||
linkToken: null
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +32,9 @@ const mutations = {
|
||||
SET_TOKEN: (state, token) => {
|
||||
state.token = token
|
||||
},
|
||||
SET_LINK_TOKEN: (state, linkToken) => {
|
||||
state.linkToken = linkToken
|
||||
},
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
},
|
||||
@ -165,6 +169,9 @@ const actions = {
|
||||
commit('SET_LANGUAGE', language)
|
||||
router.go(0)
|
||||
})
|
||||
},
|
||||
setLinkToken({ commit }, linkToken) {
|
||||
commit('SET_LINK_TOKEN', linkToken)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,10 @@ service.interceptors.request.use(
|
||||
if ((linkToken = getLinkToken()) !== null) {
|
||||
config.headers[LinkTokenKey] = linkToken
|
||||
}
|
||||
if (!linkToken) {
|
||||
linkToken = store.getters.linkToken
|
||||
config.headers[LinkTokenKey] = linkToken
|
||||
}
|
||||
|
||||
if (i18n.locale) {
|
||||
const lang = i18n.locale.replace('_', '-')
|
||||
@ -92,6 +96,7 @@ const checkAuth = response => {
|
||||
if (response.headers[LinkTokenKey.toLocaleLowerCase()] || (response.config.headers && response.config.headers[LinkTokenKey.toLocaleLowerCase()])) {
|
||||
const linkToken = response.headers[LinkTokenKey.toLocaleLowerCase()] || response.config.headers[LinkTokenKey.toLocaleLowerCase()]
|
||||
setLinkToken(linkToken)
|
||||
store.dispatch('user/setLinkToken', linkToken)
|
||||
}
|
||||
// 许可状态改变 刷新页面
|
||||
// if (response.headers['lic-status']) {
|
||||
|
Loading…
Reference in New Issue
Block a user