Skip to content

Commit

Permalink
refine: GetUserInfo error message
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Jan 11, 2019
1 parent 67c0602 commit 94ed283
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ router.beforeEach((to, from, next) => {
})
}).catch((err) => {
store.dispatch('FedLogOut').then(() => {
Message.error(err || 'Verification failed, please login again')
Message.error(err)
next({ path: '/' })
})
})
Expand Down
7 changes: 4 additions & 3 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ const user = {
GetUserInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getUserInfo(state.token).then(response => {
if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack
reject('error')
// 由于mockjs 不支持自定义状态码只能这样hack
if (!response.data) {
reject('Verification failed, please login again.')
}
const data = response.data

if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', data.roles)
} else {
reject('getInfo: roles must be a non-null array !')
reject('getInfo: roles must be a non-null array!')
}

commit('SET_NAME', data.name)
Expand Down

0 comments on commit 94ed283

Please sign in to comment.