cas sso单点登录对接ok,但后端需要根路径才能使用

This commit is contained in:
clay
2022-09-01 23:30:04 +08:00
parent 5bb43271fe
commit 812a7b4595
11 changed files with 70 additions and 16 deletions

View File

@@ -7,7 +7,9 @@ import { getToken } from '@/utils/auth'
NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
const defaultSettings = require('@/settings.js')
router.beforeEach((to, from, next) => {
NProgress.start()
@@ -48,12 +50,21 @@ router.beforeEach((to, from, next) => {
}
}
} else {
debugger
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// NProgress.done()
if (!defaultSettings.casEnable) {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
}
//开启cas
if (defaultSettings.casEnable) {
window.location.href = defaultSettings.casloginUrl // 否则全部重定向到登录页
}
NProgress.done()
}
}