Skip to content

Commit

Permalink
fix: bug 修复鉴权时GetInfo与Logout双双失效导致路由死循环
Browse files Browse the repository at this point in the history
在src/permission.js鉴权时有以下流程:
1 store
2 .dispatch('GetInfo')
3 .catch(()=>{
4   store.dispatch('Logout').then(()=>{
5        next({ path: loginRoutePath, query: { redirect: to.fullPath } })
6   })
7 })
2行GetInfo的失败catch会执行触发store的Logout(4行),而Logout也失败不catch会直接resolve导致路由到loginRoutePath(5行),
loginRoutePath会再次加载src/permission.js运行store.dispatch('GetInfo'),从此死循环开始。。。
  • Loading branch information
sammeishi authored and sendya committed Aug 17, 2021
1 parent a4a7e59 commit 4747677
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ const user = {
commit('SET_ROLES', [])
storage.remove(ACCESS_TOKEN)
resolve()
}).catch(() => {
resolve()
}).catch((err) => {
console.log('logout fail:', err)
// resolve()
}).finally(() => {
})
})
Expand Down

0 comments on commit 4747677

Please sign in to comment.