Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/src/components/layout/Person.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { userApi } from '@/api/auth'
import { toLoginPage } from '@/utils/utils'
import { useCache } from '@/utils/useCache'

const { wsCache } = useCache()
const router = useRouter()
const appearanceStore = useAppearanceStoreWithOut()
const userStore = useUserStore()
Expand All @@ -36,6 +38,10 @@ const currentLanguage = computed(() => userStore.getLanguage)
const isAdmin = computed(() => userStore.isAdmin)
const isLocalUser = computed(() => !userStore.getOrigin)

const isClient = computed(() => {
return !!wsCache.get('sqlbot-platform-client')
})

const platFlag = computed(() => {
const platformInfo = userStore.getPlatformInfo
return platformInfo?.origin || 0
Expand Down Expand Up @@ -184,7 +190,7 @@ const logout = async () => {
<div class="datasource-name">{{ $t('common.help') }}</div>
</div>
<div style="height: 4px; width: 100%"></div>
<div v-if="platFlag <= 5" class="popover-item mr4" @click="logout">
<div v-if="!isClient" class="popover-item mr4" @click="logout">
<el-icon size="16">
<icon_logout_outlined></icon_logout_outlined>
</el-icon>
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AuthApi } from '@/api/login'
import { useCache } from '@/utils/useCache'
import { i18n } from '@/i18n'
import { store } from './index'
import { getCurrentRouter, getQueryString } from '@/utils/utils'
import { getCurrentRouter, getQueryString, isPlatform } from '@/utils/utils'

const { wsCache } = useCache()

Expand Down Expand Up @@ -98,7 +98,10 @@ export const UserStore = defineStore('user', {
window.open(res, '_self')
return res
}
if (getQueryString('code') && getQueryString('state')?.includes('oauth2_state')) {
if (
(getQueryString('code') && getQueryString('state')?.includes('oauth2_state')) ||
isPlatform()
) {
const currentPath = getCurrentRouter()
let logout_url = location.origin + location.pathname + '#/login'
if (currentPath) {
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,21 @@ export const isLarkPlatform = () => {
return !!getQueryString('state') && !!getQueryString('code')
}

export const isPlatform = () => {
const state = getQueryString('state')
const platformArray = ['wecom', 'dingtalk', 'lark']
return (
!!state &&
!!getQueryString('code') &&
platformArray.some((item: string) => state.includes(item))
)
}

export const isPlatformClient = () => {
return !!getQueryString('client') || getQueryString('state')?.includes('client')
}

export const checkPlatform = () => {
/* export const checkPlatform = () => {
const flagArray = ['/casbi', 'oidcbi']
const pathname = window.location.pathname
if (
Expand All @@ -265,7 +275,7 @@ export const cleanPlatformFlag = () => {
const platformKey = 'out_auth_platform'
wsCache.delete(platformKey)
return false
}
} */
export function isTablet() {
const userAgent = navigator.userAgent
const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/views/login/xpack/Handler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ const casLogin = () => {
.then((res: any) => {
const token = res.access_token
if (token && isPlatformClient()) {
wsCache.set('de-platform-client', true)
wsCache.set('sqlbot-platform-client', true)
}
userStore.setToken(token)
userStore.setExp(res.exp)
Expand Down Expand Up @@ -358,7 +358,7 @@ const oauth2Login = () => {
const token = res.access_token
const platform_info = res.platform_info
if (token && isPlatformClient()) {
wsCache.set('de-platform-client', true)
wsCache.set('sqlbot-platform-client', true)
}
userStore.setToken(token)
userStore.setExp(res.exp)
Expand Down Expand Up @@ -391,7 +391,7 @@ const oidcLogin = () => {
const token = res.access_token
const platform_info = res.platform_info
if (token && isPlatformClient()) {
wsCache.set('de-platform-client', true)
wsCache.set('sqlbot-platform-client', true)
}
userStore.setToken(token)
userStore.setExp(res.exp)
Expand Down Expand Up @@ -424,7 +424,7 @@ const wecomLogin = () => {
const token = res.access_token
// const platform_info = res.platform_info
if (token && isPlatformClient()) {
wsCache.set('de-platform-client', true)
wsCache.set('sqlbot-platform-client', true)
}
userStore.setToken(token)
userStore.setExp(res.exp)
Expand Down Expand Up @@ -457,7 +457,7 @@ const dingtalkLogin = () => {
const token = res.access_token
// const platform_info = res.platform_info
if (token && isPlatformClient()) {
wsCache.set('de-platform-client', true)
wsCache.set('sqlbot-platform-client', true)
}
userStore.setToken(token)
userStore.setExp(res.exp)
Expand Down Expand Up @@ -495,7 +495,7 @@ const dingtalkLogin = () => {
}
const token = res.token
if (token && isPlatformClient()) {
wsCache.set('de-platform-client', true)
wsCache.set('sqlbot-platform-client', true)
}
userStore.setToken(token)
userStore.setExp(res.exp)
Expand Down Expand Up @@ -647,7 +647,7 @@ onMounted(() => {
updateLoading(false, 100)
return
}
wsCache.delete('de-platform-client')
wsCache.delete('sqlbot-platform-client')
init(async () => {
const state = callBackType()
if (state?.includes('cas') && getQueryString('ticket')) {
Expand Down