Selaa lähdekoodia

fix: next to login when token is not right

Pan 7 vuotta sitten
vanhempi
commit
576e37762a
1 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. 6 0
      src/permission.js

+ 6 - 0
src/permission.js

2
 import store from './store'
2
 import store from './store'
3
 import NProgress from 'nprogress' // Progress 进度条
3
 import NProgress from 'nprogress' // Progress 进度条
4
 import 'nprogress/nprogress.css'// Progress 进度条样式
4
 import 'nprogress/nprogress.css'// Progress 进度条样式
5
+import { Message } from 'element-ui'
5
 import { getToken } from '@/utils/auth' // 验权
6
 import { getToken } from '@/utils/auth' // 验权
6
 
7
 
7
 const whiteList = ['/login'] // 不重定向白名单
8
 const whiteList = ['/login'] // 不重定向白名单
14
       if (store.getters.roles.length === 0) {
15
       if (store.getters.roles.length === 0) {
15
         store.dispatch('GetInfo').then(res => { // 拉取用户信息
16
         store.dispatch('GetInfo').then(res => { // 拉取用户信息
16
           next()
17
           next()
18
+        }).catch(() => {
19
+          store.dispatch('FedLogOut').then(() => {
20
+            Message.error('验证失败,请重新登录')
21
+            next({ path: '/login' })
22
+          })
17
         })
23
         })
18
       } else {
24
       } else {
19
         next()
25
         next()