jinhui.wang

路由更新

import router from './router'
import store from './store'
import { Message } from 'element-ui'
import { getToken,setToken } from '@/utils/auth'
import { getToken } from '@/utils/auth'
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
// window.location.href = "https://test.secure.fedex.com/logout";//wsso系统跳转
router.beforeEach((to, from, next) => {
if (getToken()) {
/* has token*/
......@@ -21,32 +21,23 @@ router.beforeEach((to, from, next) => {
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
})
}).catch(err => {
store.dispatch('LogOut').then(() => {
Message.error(err)
store.dispatch('LogOut').then(() => {
// next({ path: '/' })
window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
})
next({ path: '/' })
})
})
} else {
next()
}
}
} else {
// 没有token
//wsso登录时对后端重定向带来的token进行记录
let token = location.search.split("token=")[1]
if(token != undefined && token != '' && token != null){
setToken(token)
next({ path: '/' })
}else{
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
}
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
}
}
})
......