cas 单点登录完成

This commit is contained in:
clay
2022-09-05 22:53:45 +08:00
parent 812a7b4595
commit a186667478
10 changed files with 85 additions and 12 deletions

View File

@@ -4,11 +4,12 @@ import { Message } from 'element-ui'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth'
import axios from "axios";
NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
const whiteList = ['/login', '/auth-redirect', '/bind', '/register','/cas-login','logout']
const defaultSettings = require('@/settings.js')
router.beforeEach((to, from, next) => {
@@ -50,17 +51,20 @@ router.beforeEach((to, from, next) => {
}
}
} else {
debugger
// debugger
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
// next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// axios.get("http://192.168.190.67/dev-api/cas-login").then(res=>{
//
// })
// NProgress.done()
if (!defaultSettings.casEnable) {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
}
// if (!defaultSettings.casEnable) {
// next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// }
//开启cas
if (defaultSettings.casEnable) {
window.location.href = defaultSettings.casloginUrl // 否则全部重定向到登录页