Skip to content

Commit 85f73ee

Browse files
perf: QR Code Login Stuck / Unable to Log Out
1 parent 14e13d1 commit 85f73ee

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

frontend/src/components/layout/Person.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import { useRouter } from 'vue-router'
1919
import { useUserStore } from '@/stores/user'
2020
import { userApi } from '@/api/auth'
2121
import { toLoginPage } from '@/utils/utils'
22+
import { useCache } from '@/utils/useCache'
2223
24+
const { wsCache } = useCache()
2325
const router = useRouter()
2426
const appearanceStore = useAppearanceStoreWithOut()
2527
const userStore = useUserStore()
@@ -36,6 +38,10 @@ const currentLanguage = computed(() => userStore.getLanguage)
3638
const isAdmin = computed(() => userStore.isAdmin)
3739
const isLocalUser = computed(() => !userStore.getOrigin)
3840
41+
const isClient = computed(() => {
42+
return !!wsCache.get('sqlbot-platform-client')
43+
})
44+
3945
const platFlag = computed(() => {
4046
const platformInfo = userStore.getPlatformInfo
4147
return platformInfo?.origin || 0
@@ -184,7 +190,7 @@ const logout = async () => {
184190
<div class="datasource-name">{{ $t('common.help') }}</div>
185191
</div>
186192
<div style="height: 4px; width: 100%"></div>
187-
<div v-if="platFlag <= 5" class="popover-item mr4" @click="logout">
193+
<div v-if="!isClient" class="popover-item mr4" @click="logout">
188194
<el-icon size="16">
189195
<icon_logout_outlined></icon_logout_outlined>
190196
</el-icon>

frontend/src/stores/user.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AuthApi } from '@/api/login'
44
import { useCache } from '@/utils/useCache'
55
import { i18n } from '@/i18n'
66
import { store } from './index'
7-
import { getCurrentRouter, getQueryString } from '@/utils/utils'
7+
import { getCurrentRouter, getQueryString, isPlatform } from '@/utils/utils'
88

99
const { wsCache } = useCache()
1010

@@ -98,7 +98,10 @@ export const UserStore = defineStore('user', {
9898
window.open(res, '_self')
9999
return res
100100
}
101-
if (getQueryString('code') && getQueryString('state')?.includes('oauth2_state')) {
101+
if (
102+
(getQueryString('code') && getQueryString('state')?.includes('oauth2_state')) ||
103+
isPlatform()
104+
) {
102105
const currentPath = getCurrentRouter()
103106
let logout_url = location.origin + location.pathname + '#/login'
104107
if (currentPath) {

frontend/src/utils/utils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,21 @@ export const isLarkPlatform = () => {
245245
return !!getQueryString('state') && !!getQueryString('code')
246246
}
247247

248+
export const isPlatform = () => {
249+
const state = getQueryString('state')
250+
const platformArray = ['wecom', 'dingtalk', 'lark']
251+
return (
252+
!!state &&
253+
!!getQueryString('code') &&
254+
platformArray.some((item: string) => state.includes(item))
255+
)
256+
}
257+
248258
export const isPlatformClient = () => {
249259
return !!getQueryString('client') || getQueryString('state')?.includes('client')
250260
}
251261

252-
export const checkPlatform = () => {
262+
/* export const checkPlatform = () => {
253263
const flagArray = ['/casbi', 'oidcbi']
254264
const pathname = window.location.pathname
255265
if (
@@ -265,7 +275,7 @@ export const cleanPlatformFlag = () => {
265275
const platformKey = 'out_auth_platform'
266276
wsCache.delete(platformKey)
267277
return false
268-
}
278+
} */
269279
export function isTablet() {
270280
const userAgent = navigator.userAgent
271281
const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ const casLogin = () => {
325325
.then((res: any) => {
326326
const token = res.access_token
327327
if (token && isPlatformClient()) {
328-
wsCache.set('de-platform-client', true)
328+
wsCache.set('sqlbot-platform-client', true)
329329
}
330330
userStore.setToken(token)
331331
userStore.setExp(res.exp)
@@ -358,7 +358,7 @@ const oauth2Login = () => {
358358
const token = res.access_token
359359
const platform_info = res.platform_info
360360
if (token && isPlatformClient()) {
361-
wsCache.set('de-platform-client', true)
361+
wsCache.set('sqlbot-platform-client', true)
362362
}
363363
userStore.setToken(token)
364364
userStore.setExp(res.exp)
@@ -391,7 +391,7 @@ const oidcLogin = () => {
391391
const token = res.access_token
392392
const platform_info = res.platform_info
393393
if (token && isPlatformClient()) {
394-
wsCache.set('de-platform-client', true)
394+
wsCache.set('sqlbot-platform-client', true)
395395
}
396396
userStore.setToken(token)
397397
userStore.setExp(res.exp)
@@ -424,7 +424,7 @@ const wecomLogin = () => {
424424
const token = res.access_token
425425
// const platform_info = res.platform_info
426426
if (token && isPlatformClient()) {
427-
wsCache.set('de-platform-client', true)
427+
wsCache.set('sqlbot-platform-client', true)
428428
}
429429
userStore.setToken(token)
430430
userStore.setExp(res.exp)
@@ -457,7 +457,7 @@ const dingtalkLogin = () => {
457457
const token = res.access_token
458458
// const platform_info = res.platform_info
459459
if (token && isPlatformClient()) {
460-
wsCache.set('de-platform-client', true)
460+
wsCache.set('sqlbot-platform-client', true)
461461
}
462462
userStore.setToken(token)
463463
userStore.setExp(res.exp)
@@ -495,7 +495,7 @@ const dingtalkLogin = () => {
495495
}
496496
const token = res.token
497497
if (token && isPlatformClient()) {
498-
wsCache.set('de-platform-client', true)
498+
wsCache.set('sqlbot-platform-client', true)
499499
}
500500
userStore.setToken(token)
501501
userStore.setExp(res.exp)
@@ -647,7 +647,7 @@ onMounted(() => {
647647
updateLoading(false, 100)
648648
return
649649
}
650-
wsCache.delete('de-platform-client')
650+
wsCache.delete('sqlbot-platform-client')
651651
init(async () => {
652652
const state = callBackType()
653653
if (state?.includes('cas') && getQueryString('ticket')) {

0 commit comments

Comments
 (0)