Skip to content
Snippets Groups Projects
Commit 9fbb0281 authored by Pan's avatar Pan
Browse files

perf[permission]: add the verification of roles

parent 9b5f0160
Branches develop
No related tags found
No related merge requests found
...@@ -31,10 +31,10 @@ router.beforeEach((to, from, next) => { ...@@ -31,10 +31,10 @@ router.beforeEach((to, from, next) => {
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
}) })
}).catch(() => { }).catch((err) => {
store.dispatch('FedLogOut').then(() => { store.dispatch('FedLogOut').then(() => {
Message.error('Verification failed, please login again') Message.error(err || 'Verification failed, please login again')
next({ path: '/login' }) next({ path: '/' })
}) })
}) })
} else { } else {
......
...@@ -67,7 +67,13 @@ const user = { ...@@ -67,7 +67,13 @@ const user = {
reject('error') reject('error')
} }
const data = response.data const data = response.data
commit('SET_ROLES', data.roles)
if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', data.roles)
} else {
reject('getInfo: roles must be a non-null array !')
}
commit('SET_NAME', data.name) commit('SET_NAME', data.name)
commit('SET_AVATAR', data.avatar) commit('SET_AVATAR', data.avatar)
commit('SET_INTRODUCTION', data.introduction) commit('SET_INTRODUCTION', data.introduction)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment