Commit 67e04171 authored by wzy's avatar wzy

fix: 隐藏单点登录

parent 5ef9c8b6
......@@ -8,7 +8,7 @@ import '@/global/styles/global.less'; // 导入全局样式
import 'antd/dist/antd.less'
import { isDev } from '@/constants'
import { setup } from '@formily/antd-components';
import { getRouters, getAuth, asyncRouter, setRouters, removeAuth, setEnableMultiTenancy, removeEnableMultiTenancy } from './utils/auth';
import { getRouters, getAuth, asyncRouter, setRouters, removeAuth, setEnableMultiTenancy, removeEnableMultiTenancy, setAuth, removeRouters } from './utils/auth';
// 全局注册虚拟组件
import '@/components/NiceForm/public'
import LRU from '@/utils/lru';
......@@ -95,11 +95,28 @@ export function render(oldRender: Function) {
oldRender()
return;
}
keycloakThen().then(() => {
const isAuth = isAuthenticated()
// keycloakThen().then(() => {
// const isAuth = isAuthenticated()
const authInfo = getAuth()
if (!(authInfo && isAuth)) {
setAuthInfo().finally(() => {
if (!(authInfo)) {
// if (!(authInfo && isAuth)) {
// setAuthInfo().finally(() => {
// oldRender()
// })
getMemberLoginReget({}, { useCache: true, ttl: 1000 }).then(res => {
const { data, code } = res
if (code === 1000) {
setAuth(data as any)
setRouters(data.auth)
} else {
removeAuth()
removeRouters()
history.replace('/user/login')
// SpaLogin()
}
oldRender()
}).catch(() => {
oldRender()
})
getManagePaasSiteEnableMultiTenancy({ siteId: GlobalConfig.global.siteInfo.id.toString() }).then(res => {
......@@ -109,15 +126,15 @@ export function render(oldRender: Function) {
setEnableMultiTenancy(res.data);
})
} else {
if (!isAuth) {
// if (!isAuth) {
SpaLogout()
removeAuth()
// removeRouters()
removeRouters()
removeEnableMultiTenancy()
}
// }
oldRender()
}
})
// })
// return
}
......
......@@ -16,7 +16,7 @@ const AvatarDropdown = (props) => {
const userAuth = getAuth();
const logout = () => {
removeAuth()
// removeRouters()
removeRouters()
SpaLogout()
// history.replace('/user/login')
}
......
......@@ -136,7 +136,7 @@ export const removeAuth = () => {
removeCookie('currentMallLink', { path: '/', domain: getTopDomainByHost(TOP_DOMAIN_NO_PORT, true) })
window.localStorage.removeItem(AUTH_KEY)
removeEnableMultiTenancy()
// removeRouters()
removeRouters()
const _window: any = window
_window?.ysf && _window.ysf('logoff')
}
......
......@@ -69,6 +69,6 @@ export function SpaLogin() {
}
export function SpaLogout() {
// console.log(getKeycloak())
getKeycloak().logout()
history.replace('/user/login')
// getKeycloak().logout()
}
......@@ -135,8 +135,8 @@ class ApiRequest {
// 登录验证
if (res.code === 1101) {
removeAuth()
SpaLogout()
// window.location.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
// SpaLogout()
window.location.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
message.destroy()
message.error(res.message)
reject(res)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment