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
4 changes: 2 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, isPlatform } from '@/utils/utils'
import { getCurrentRouter, getQueryString, getSQLBotAddr, isPlatform } from '@/utils/utils'

const { wsCache } = useCache()

Expand Down Expand Up @@ -103,7 +103,7 @@ export const UserStore = defineStore('user', {
isPlatform()
) {
const currentPath = getCurrentRouter()
let logout_url = location.origin + location.pathname + '#/login'
let logout_url = getSQLBotAddr() + '#/login'
if (currentPath) {
logout_url += `?redirect=${currentPath}`
}
Expand Down
28 changes: 11 additions & 17 deletions frontend/src/views/login/xpack/Handler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { useCache } from '@/utils/useCache'

import router from '@/router'
import { useUserStore } from '@/stores/user.ts'
import { getQueryString, getUrlParams, isPlatformClient } from '@/utils/utils'
import { getQueryString, getSQLBotAddr, getUrlParams, isPlatformClient } from '@/utils/utils'
import { loadClient, type LoginCategory } from './PlatformClient'
// import MfaStep from './MfaStep.vue'
// import { logoutHandler } from '@/utils/logout'
Expand Down Expand Up @@ -344,8 +344,7 @@ const casLogin = () => {
// logoutHandler(true, true)
platformLoginMsg.value = e?.message || e
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
window.location.href = getSQLBotAddr() + window.location.hash
}, 2000)
}, 1500)
})
Expand Down Expand Up @@ -377,8 +376,7 @@ const oauth2Login = () => {
// logoutHandler(true, true)
platformLoginMsg.value = e?.message || e
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
window.location.href = getSQLBotAddr() + window.location.hash
}, 2000)
}, 1500)
})
Expand Down Expand Up @@ -410,8 +408,7 @@ const oidcLogin = () => {
// logoutHandler(true, true)
platformLoginMsg.value = e?.message || e
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
window.location.href = getSQLBotAddr() + window.location.hash
}, 2000)
}, 1500)
})
Expand Down Expand Up @@ -443,15 +440,14 @@ const wecomLogin = () => {
// logoutHandler(true, true)
platformLoginMsg.value = e?.message || e
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
window.location.href = getSQLBotAddr() + window.location.hash
}, 2000)
}, 1500)
})
}
const larkLogin = () => {
const urlParams = getUrlParams()
urlParams['redirect_uri'] = encodeURIComponent(window.location.origin + window.location.pathname)
urlParams['redirect_uri'] = encodeURIComponent(getSQLBotAddr())
request
.post('/system/platform/sso/8', urlParams)
.then((res: any) => {
Expand All @@ -477,8 +473,7 @@ const larkLogin = () => {
// logoutHandler(true, true)
platformLoginMsg.value = e?.message || e
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
window.location.href = getSQLBotAddr() + window.location.hash
}, 2000)
}, 1500)
})
Expand Down Expand Up @@ -510,8 +505,7 @@ const dingtalkLogin = () => {
// logoutHandler(true, true)
platformLoginMsg.value = e?.message || e
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
window.location.href = getSQLBotAddr() + window.location.hash
}, 2000)
}, 1500)
})
Expand All @@ -536,7 +530,7 @@ const dingtalkLogin = () => {
userStore.setTime(Date.now())
if (origin === 10 || isLarkPlatform()) {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
getSQLBotAddr() + window.location.hash
} else {
const queryRedirectPath = getCurLocation()
router.push({ path: queryRedirectPath })
Expand All @@ -547,7 +541,7 @@ const dingtalkLogin = () => {
if (isLarkPlatform()) {
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
getSQLBotAddr() + window.location.hash
}, 2000)
} else {
setTimeout(() => {
Expand Down Expand Up @@ -613,7 +607,7 @@ const oauth2Token = (cb) => {
.catch(() => {
setTimeout(() => {
window.location.href =
window.location.origin + window.location.pathname + window.location.hash
getSQLBotAddr() + window.location.hash
}, 2000)
})
}
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/views/login/xpack/PlatformClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadScript } from '@/utils/RemoteJs'
import { getQueryString } from '@/utils/utils'
import { getCurrentRouter, getQueryString } from '@/utils/utils'
import { ElMessage, ElMessageBox } from 'element-plus-secondary'

// import { useI18n } from 'vue-i18n'
Expand Down Expand Up @@ -35,7 +35,7 @@ export const loadClient = (category: LoginCategory) => {
const type = getQueryString('client')
const corpid = getQueryString('corpid')
if (type && !category[type as keyof LoginCategory]) {
ElMessageBox.confirm(t('login.platform_disable', [t(`threshold.${type}`)]), {
ElMessageBox.confirm(t('login.platform_disable', [t(`user.${type}`)]), {
confirmButtonType: 'danger',
type: 'warning',
showCancelButton: false,
Expand Down Expand Up @@ -173,5 +173,7 @@ const larksuiteClientRequest = async () => {

const toUrl = (url: string) => {
const { origin, pathname } = window.location
window.location.href = origin + pathname + url
const redirect = getCurrentRouter()
window.location.href =
origin + pathname + url + (redirect?.includes('chatPreview') ? `#${redirect}` : '')
}
11 changes: 6 additions & 5 deletions frontend/src/views/system/authentication/SAML2Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ElMessage, ElLoading } from 'element-plus-secondary'
import { useI18n } from 'vue-i18n'
import type { FormInstance, FormRules } from 'element-plus-secondary'
import { request } from '@/utils/request'
import { getSQLBotAddr } from '@/utils/utils'
const { t } = useI18n()
const dialogVisible = ref(false)
const loadingInstance = ref<ReturnType<typeof ElLoading.service> | null>(null)
Expand All @@ -28,7 +29,7 @@ const state = reactive({
})

/* const spMetaDataUrl = ref('')
spMetaDataUrl.value = location.origin + location.pathname + 'saml/metadata' */
spMetaDataUrl.value = getSQLBotAddr() + 'saml/metadata' */

const rule = reactive<FormRules>({
/* idpUri: [
Expand Down Expand Up @@ -72,8 +73,8 @@ const submitForm = async (formEl: FormInstance | undefined) => {
await formEl.validate((valid) => {
if (valid) {
const param = { ...state.form } as any
param['spEntityId'] = location.origin + location.pathname + 'saml/metadata'
param['spAcs'] = location.origin + location.pathname + 'saml/sso'
param['spEntityId'] = getSQLBotAddr() + 'saml/metadata'
param['spAcs'] = getSQLBotAddr() + 'saml/sso'
const method = request.post('/setting/authentication/save/saml', param)
showLoading()
method
Expand Down Expand Up @@ -114,8 +115,8 @@ const closeLoading = () => {
const validate = () => {
const url = '/setting/authentication/validate/saml2'
const data = { ...state.form } as any
data['spEntityId'] = location.origin + location.pathname + 'saml/metadata'
data['spAcs'] = location.origin + location.pathname + 'saml/sso'
data['spEntityId'] = getSQLBotAddr() + 'saml/metadata'
data['spAcs'] = getSQLBotAddr() + 'saml/sso'
showLoading()
request
.post(url, data)
Expand Down