fix: fix getUserInfo by cookie bug
This commit is contained in:
parent
87a44ae7f5
commit
76f4017470
|
@ -34,7 +34,7 @@ export default {
|
||||||
if (userMap[token]) {
|
if (userMap[token]) {
|
||||||
return userMap[token]
|
return userMap[token]
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject('error')
|
return false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
logout: () => 'success'
|
logout: () => 'success'
|
||||||
|
|
|
@ -3,6 +3,7 @@ import store from './store'
|
||||||
import NProgress from 'nprogress' // Progress 进度条
|
import NProgress from 'nprogress' // Progress 进度条
|
||||||
import 'nprogress/nprogress.css'// Progress 进度条样式
|
import 'nprogress/nprogress.css'// Progress 进度条样式
|
||||||
import { getToken } from '@/utils/auth' // 验权
|
import { getToken } from '@/utils/auth' // 验权
|
||||||
|
import { Message } from 'element-ui'
|
||||||
|
|
||||||
// permissiom judge
|
// permissiom judge
|
||||||
function hasPermission(roles, permissionRoles) {
|
function hasPermission(roles, permissionRoles) {
|
||||||
|
@ -29,6 +30,7 @@ router.beforeEach((to, from, next) => {
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
store.dispatch('FedLogOut').then(() => {
|
store.dispatch('FedLogOut').then(() => {
|
||||||
|
Message.error('验证失败,请重新登录')
|
||||||
next({ path: '/login' })
|
next({ path: '/login' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -63,6 +63,9 @@ const user = {
|
||||||
GetUserInfo({ commit, state }) {
|
GetUserInfo({ commit, state }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getUserInfo(state.token).then(response => {
|
getUserInfo(state.token).then(response => {
|
||||||
|
if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack
|
||||||
|
reject('error')
|
||||||
|
}
|
||||||
const data = response.data
|
const data = response.data
|
||||||
commit('SET_ROLES', data.role)
|
commit('SET_ROLES', data.role)
|
||||||
commit('SET_NAME', data.name)
|
commit('SET_NAME', data.name)
|
||||||
|
|
Loading…
Reference in New Issue