diff --git a/cmdb-ui/src/api/auth.js b/cmdb-ui/src/api/auth.js
index 355a4f4..4e23e72 100644
--- a/cmdb-ui/src/api/auth.js
+++ b/cmdb-ui/src/api/auth.js
@@ -29,3 +29,12 @@ export function getAuthDataEnable() {
method: 'get',
})
}
+
+
+export function testLDAP(test_type, data) {
+ return axios({
+ url: `/common-setting/v1/auth_config/LDAP/test?test_type=${test_type}`,
+ method: 'post',
+ data,
+ })
+}
diff --git a/cmdb-ui/src/utils/request.js b/cmdb-ui/src/utils/request.js
index cca37bb..3ac2dfb 100644
--- a/cmdb-ui/src/utils/request.js
+++ b/cmdb-ui/src/utils/request.js
@@ -5,6 +5,7 @@ import { VueAxios } from './axios'
import message from 'ant-design-vue/es/message'
import notification from 'ant-design-vue/es/notification'
import { ACCESS_TOKEN } from '@/store/global/mutation-types'
+import router from '@/router'
// 创建 axios 实例
const service = axios.create({
@@ -50,7 +51,7 @@ const err = (error) => {
}
if (error.response) {
console.log(error.config.url)
- if (error.response.status === 401) {
+ if (error.response.status === 401 && router.path === '/user/login') {
window.location.href = '/user/logout'
}
}
diff --git a/cmdb-ui/src/views/setting/auth/index.vue b/cmdb-ui/src/views/setting/auth/index.vue
index 313cdb2..5218429 100644
--- a/cmdb-ui/src/views/setting/auth/index.vue
+++ b/cmdb-ui/src/views/setting/auth/index.vue
@@ -12,13 +12,20 @@
-
+
+
+
+ 保存
+
+ 测试链接
+ 测试登录
+
+ 重置
+
+
+
+ handleTest('login', values)" />
@@ -29,10 +36,11 @@ import LDAP from './ldap.vue'
import CAS from './cas.vue'
import AuthCommonConfig from './common.vue'
import OAUTH2 from './oauth2.vue'
-import { getAuthData, postAuthData, putAuthData, getAuthDataEnable } from '@/api/auth'
+import LoginModal from './loginModal.vue'
+import { getAuthData, postAuthData, putAuthData, getAuthDataEnable, testLDAP } from '@/api/auth'
export default {
name: 'Auth',
- components: { LDAP, CAS, AuthCommonConfig, OAUTH2 },
+ components: { LDAP, CAS, AuthCommonConfig, OAUTH2, LoginModal },
data() {
const authList = [
{
@@ -76,7 +84,7 @@ export default {
},
changeActiveKey() {
getAuthData(this.activeKey).then((res) => {
- const _res = _.cloneDeep(res)
+ const _res = _.cloneDeep(res)
this.$refs[this.activeKey][0].setData(_res?.data ?? null)
if (_res && JSON.stringify(_res) !== '{}') {
this.dataTypeId = _res.id
@@ -105,6 +113,29 @@ export default {
handleReset() {
this.changeActiveKey()
},
+ handleTest(type, values = null) {
+ this.$refs[this.activeKey][0].getData(async (data) => {
+ if (type === 'login' && !values) {
+ this.$refs.loginModal[0].open()
+ } else {
+ this.loading = true
+ let _data = _.cloneDeep(data)
+ if (values) {
+ _data = {
+ ..._data,
+ ...values,
+ }
+ }
+ testLDAP(type, { data: _data })
+ .then((res) => {
+ this.$message.success('测试成功')
+ })
+ .finally(() => {
+ this.loading = false
+ })
+ }
+ })
+ },
},
}
@@ -116,10 +147,6 @@ export default {
overflow: auto;
border-radius: 0 5px 5px 5px;
padding-top: 24px;
- .setting-auth-operation {
- padding: 0 100px 24px 100px;
- text-align: right;
- }
}
diff --git a/cmdb-ui/src/views/setting/auth/loginModal.vue b/cmdb-ui/src/views/setting/auth/loginModal.vue
new file mode 100644
index 0000000..5f6b9b2
--- /dev/null
+++ b/cmdb-ui/src/views/setting/auth/loginModal.vue
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file