fix: Token conflict issue between two different applications embedded in the same system(#2753)
This commit is contained in:
parent
0e98c7783b
commit
081fcab7eb
@ -97,8 +97,8 @@ const useApplicationStore = defineStore({
|
|||||||
applicationApi
|
applicationApi
|
||||||
.postAppAuthentication(token, loading, authentication_value)
|
.postAppAuthentication(token, loading, authentication_value)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
localStorage.setItem('accessToken', res.data)
|
localStorage.setItem(`${token}accessToken`, res.data)
|
||||||
sessionStorage.setItem('accessToken', res.data)
|
sessionStorage.setItem(`${token}accessToken`, res.data)
|
||||||
resolve(res)
|
resolve(res)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export interface userStateTypes {
|
|||||||
userInfo: User | null
|
userInfo: User | null
|
||||||
token: any
|
token: any
|
||||||
version?: string
|
version?: string
|
||||||
accessToken?: string
|
userAccessToken?: string
|
||||||
XPACK_LICENSE_IS_VALID: false
|
XPACK_LICENSE_IS_VALID: false
|
||||||
isXPack: false
|
isXPack: false
|
||||||
themeInfo: any
|
themeInfo: any
|
||||||
@ -26,6 +26,7 @@ const useUserStore = defineStore({
|
|||||||
userInfo: null,
|
userInfo: null,
|
||||||
token: '',
|
token: '',
|
||||||
version: '',
|
version: '',
|
||||||
|
userAccessToken: '',
|
||||||
XPACK_LICENSE_IS_VALID: false,
|
XPACK_LICENSE_IS_VALID: false,
|
||||||
isXPack: false,
|
isXPack: false,
|
||||||
themeInfo: null
|
themeInfo: null
|
||||||
@ -60,11 +61,11 @@ const useUserStore = defineStore({
|
|||||||
return this.userType === 1 ? localStorage.getItem('token') : this.getAccessToken()
|
return this.userType === 1 ? localStorage.getItem('token') : this.getAccessToken()
|
||||||
},
|
},
|
||||||
getAccessToken() {
|
getAccessToken() {
|
||||||
const accessToken = sessionStorage.getItem('accessToken')
|
const token = sessionStorage.getItem(`${this.userAccessToken}accessToken`)
|
||||||
if (accessToken) {
|
if (token) {
|
||||||
return accessToken
|
return token
|
||||||
}
|
}
|
||||||
return localStorage.getItem('accessToken')
|
return localStorage.getItem(`${this.userAccessToken}accessToken`)
|
||||||
},
|
},
|
||||||
|
|
||||||
getPermissions() {
|
getPermissions() {
|
||||||
@ -83,8 +84,9 @@ const useUserStore = defineStore({
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeUserType(num: number) {
|
changeUserType(num: number, token?: string) {
|
||||||
this.userType = num
|
this.userType = num
|
||||||
|
this.userAccessToken = token
|
||||||
},
|
},
|
||||||
|
|
||||||
async asyncGetProfile() {
|
async asyncGetProfile() {
|
||||||
|
|||||||
@ -92,7 +92,7 @@ function getAccessToken(token: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
user.changeUserType(2)
|
user.changeUserType(2, accessToken)
|
||||||
Promise.all([user.asyncGetProfile(), getAccessToken(accessToken)])
|
Promise.all([user.asyncGetProfile(), getAccessToken(accessToken)])
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
applicationAvailable.value = false
|
applicationAvailable.value = false
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user