url认证
This commit is contained in:
@@ -290,10 +290,30 @@ let router = new Router({
|
||||
|
||||
// 使用 router.beforeEach 注册一个全局前置守卫,判断用户是否登陆
|
||||
router.beforeEach((to, from, next) => {
|
||||
let userInfo = local.getUserByCache()
|
||||
if(userInfo != null){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'http://juip.wyk/api/Allow/urlCheck',
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data: {'url':to.fullPath,'id':userInfo.Manager.ID},
|
||||
success: function (res) {
|
||||
if(res.Code == -10000){
|
||||
router.replace({
|
||||
path: '/login',
|
||||
query: {
|
||||
redirect: router.currentRoute.fullPath
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (to.path === '/login' || to.path === '/' || to.path === '/r') {
|
||||
next()
|
||||
} else {
|
||||
let userInfo = local.getUserByCache()// localStorage.getItem('etorcurrentuser');
|
||||
// localStorage.getItem('etorcurrentuser');
|
||||
if (!userInfo || userInfo === '') {
|
||||
router.replace({
|
||||
path: '/login',
|
||||
|
||||
Reference in New Issue
Block a user