Skip to content

Commit 9530877

Browse files
perf(X-Pack): Optimize third-party authentication platform integration
1 parent 4c8b463 commit 9530877

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

frontend/src/stores/user.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ export const UserStore = defineStore('user', {
8181
},
8282

8383
async logout() {
84-
const param = { ...{ token: this.token }, ...this.platformInfo }
84+
let param = { token: this.token }
85+
if (wsCache.get('user.platformInfo')) {
86+
param = { ...param, ...wsCache.get('user.platformInfo') }
87+
}
8588
const res: any = await AuthApi.logout(param)
8689
this.clear()
8790
if (res) {

frontend/src/views/login/index.vue

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<template>
2-
<div class="login-container">
2+
<div
3+
v-if="showLoading"
4+
v-loading="true"
5+
:element-loading-text="t('qa.loading')"
6+
class="xpack-login-handler-mask"
7+
element-loading-background="#F5F6F7"
8+
></div>
9+
10+
<div class="login-container" :class="{ 'hide-login-container': showLoading }">
311
<div class="login-left">
412
<img :src="bg" alt="" />
513
</div>
@@ -52,7 +60,11 @@
5260
}}</el-button>
5361
</el-form-item>
5462
</el-form>
55-
<Handler ref="xpackLoginHandler" jsname="L2NvbXBvbmVudC9sb2dpbi9IYW5kbGVy" />
63+
<Handler
64+
ref="xpackLoginHandler"
65+
v-model:loading="showLoading"
66+
jsname="L2NvbXBvbmVudC9sb2dpbi9IYW5kbGVy"
67+
/>
5668
</div>
5769
</div>
5870
</div>
@@ -71,6 +83,7 @@ import { useAppearanceStoreWithOut } from '@/stores/appearance'
7183
import loginImage from '@/assets/blue/login-image_blue.png'
7284
import Handler from './xpack/Handler.vue'
7385
86+
const showLoading = ref(true)
7487
const router = useRouter()
7588
const userStore = useUserStore()
7689
const appearanceStore = useAppearanceStoreWithOut()
@@ -194,8 +207,18 @@ const submitForm = () => {
194207
}
195208
}
196209
}
197-
210+
.hide-login-container {
211+
display: none;
212+
}
198213
:deep(.ed-input__wrapper) {
199214
background-color: #f5f7fa;
200215
}
216+
.xpack-login-handler-mask {
217+
position: fixed;
218+
width: 100vw;
219+
height: 100vh;
220+
left: 0;
221+
top: 0;
222+
z-index: 999;
223+
}
201224
</style>

frontend/src/views/login/xpack/Handler.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ import { loadClient, type LoginCategory } from './PlatformClient'
5050
// import { logoutHandler } from '@/utils/logout'
5151
import { useI18n } from 'vue-i18n'
5252
// import PlatformError from './PlatformError.vue'
53-
53+
defineProps<{
54+
loading: boolean
55+
}>()
56+
const emits = defineEmits(['switchTab', 'autoCallback', 'update:loading'])
57+
const updateLoading = (show: boolean) => {
58+
emits('update:loading', show)
59+
}
5460
const { t } = useI18n()
5561
interface Categoryparam {
5662
category: string
@@ -71,7 +77,6 @@ const saml2Handler = ref()
7177
ready: false,
7278
},
7379
}) */
74-
const emits = defineEmits(['switchTab', 'autoCallback'])
7580
const init = (cb?: () => void) => {
7681
queryCategoryStatus()
7782
.then((res) => {
@@ -195,6 +200,10 @@ const casLogin = () => {
195200
setTimeout(() => {
196201
// logoutHandler(true, true)
197202
platformLoginMsg.value = e?.message || e
203+
setTimeout(() => {
204+
window.location.href =
205+
window.location.origin + window.location.pathname + window.location.hash
206+
}, 2000)
198207
}, 1500)
199208
})
200209
}
@@ -363,13 +372,22 @@ const callBackType = () => {
363372
} */
364373
365374
onMounted(() => {
375+
// eslint-disable-next-line no-undef
376+
const obj = LicenseGenerator.getLicense()
377+
if (obj?.status !== 'valid') {
378+
updateLoading(false)
379+
return
380+
}
366381
wsCache.delete('de-platform-client')
367382
init(async () => {
368383
const state = callBackType()
369384
if (state?.includes('cas') && getQueryString('ticket')) {
370385
// platformLogin(1)
371386
casLogin()
372-
} /* else if (window.location.pathname.includes('/oidcbi/')) {
387+
} else {
388+
updateLoading(false)
389+
}
390+
/* else if (window.location.pathname.includes('/oidcbi/')) {
373391
platformLogin(2)
374392
} else if (state?.includes('dingtalk')) {
375393
await dingtalkToken()

0 commit comments

Comments
 (0)