jinhui.wang

路由更新

1 import router from './router' 1 import router from './router'
2 import store from './store' 2 import store from './store'
3 import { Message } from 'element-ui' 3 import { Message } from 'element-ui'
4 -import { getToken,setToken } from '@/utils/auth' 4 +import { getToken } from '@/utils/auth'
5 5
6 6
7 const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] 7 const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
8 - 8 +// window.location.href = "https://test.secure.fedex.com/logout";//wsso系统跳转
9 router.beforeEach((to, from, next) => { 9 router.beforeEach((to, from, next) => {
10 if (getToken()) { 10 if (getToken()) {
11 /* has token*/ 11 /* has token*/
...@@ -21,32 +21,23 @@ router.beforeEach((to, from, next) => { ...@@ -21,32 +21,23 @@ router.beforeEach((to, from, next) => {
21 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 21 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
22 }) 22 })
23 }).catch(err => { 23 }).catch(err => {
24 + store.dispatch('LogOut').then(() => {
24 Message.error(err) 25 Message.error(err)
25 - store.dispatch('LogOut').then(() => { 26 + next({ path: '/' })
26 - // next({ path: '/' })
27 - window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
28 - })
29 }) 27 })
28 + })
30 } else { 29 } else {
31 next() 30 next()
32 } 31 }
33 } 32 }
34 } else { 33 } else {
35 // 没有token 34 // 没有token
36 - //wsso登录时对后端重定向带来的token进行记录 35 + if (whiteList.indexOf(to.path) !== -1) {
37 - let token = location.search.split("token=")[1] 36 + // 在免登录白名单,直接进入
38 - if(token != undefined && token != '' && token != null){ 37 + next()
39 - setToken(token) 38 + } else {
40 - next({ path: '/' }) 39 + next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
41 - }else{
42 - if (whiteList.indexOf(to.path) !== -1) {
43 - // 在免登录白名单,直接进入
44 - next()
45 - } else {
46 - window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
47 - }
48 } 40 }
49 -
50 } 41 }
51 }) 42 })
52 43
......