Skip to content

Commit

Permalink
feat: 登录配置联调 #1643 (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri0528 authored Apr 23, 2024
1 parent 932187d commit 32c1bb7
Show file tree
Hide file tree
Showing 39 changed files with 652 additions and 8,883 deletions.
2 changes: 1 addition & 1 deletion src/pages/src/common/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const getLoginUrl = (isOpener = true) => {

// 退出登录
export const logout = () => {
location.href = getLoginUrl();
location.href = getLoginUrl(false);
};
62 changes: 2 additions & 60 deletions src/pages/src/hooks/useCustomPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { InfoBox, Message } from 'bkui-vue';
import { h, ref } from 'vue';
import { ref } from 'vue';

import { postIdps, putIdps } from '@/http';
import { t } from '@/language/index';
import { copy } from '@/utils';

export const useCustomPlugin = (formData, dataSourceList, builtinFields, customFields, btnLoading, formRef, type) => {
export const useCustomPlugin = (formData, dataSourceList, builtinFields, customFields) => {
const changeDataSourceId = (val, oldVal) => {
dataSourceList.value.forEach((item) => {
if (item.key === val) {
Expand Down Expand Up @@ -98,60 +95,6 @@ export const useCustomPlugin = (formData, dataSourceList, builtinFields, customF
window.changeInput = true;
};

const handleSubmit = async () => {
try {
await formRef.value.validate();
btnLoading.value = true;
const data = formData.value;
data.data_source_match_rules.forEach((item) => {
delete item.targetFields;
});

if (type === 'add') {
const res = await postIdps(data);

InfoBox({
title: t('认证源创建成功'),
extCls: 'info-wrapper',
subTitle: h('div', {
class: 'details-url',
style: {
display: res.data?.callback_uri ? 'block' : 'none',
},
}, [
h('p', {
class: 'title',
}, t('请将一下回调地址填写到企业微信配置内:')),
h('div', {
class: 'content',
}, [
h('p', {}, res.data?.callback_uri),
h('i', {
class: 'user-icon icon-copy',
onClick: () => copy(res.data?.callback_uri),
}),
]),
]),
dialogType: 'confirm',
confirmText: t('确定'),
infoType: 'success',
quickClose: false,
onConfirm() {
window.changeInput = false;
},
});
} else {
await putIdps(data);
Message({ theme: 'success', message: t('认证源更新成功') });
window.changeInput = false;
}
} catch (e) {
console.warn(e);
} finally {
btnLoading.value = false;
}
};

return {
changeDataSourceId,
changeSourceField,
Expand All @@ -163,7 +106,6 @@ export const useCustomPlugin = (formData, dataSourceList, builtinFields, customF
mouseenter,
mouseleave,
handleChange,
handleSubmit,
hoverItem,
};
};
16 changes: 16 additions & 0 deletions src/pages/src/http/authSourceFiles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import http from './fetch';
import type {
NewIdpsParams,
NewLocalIdpsParams,
PatchIdpsParams,
PutIdpsParams,
} from './types/authSourceFiles';
Expand Down Expand Up @@ -39,3 +40,18 @@ export const putIdps = (params: PutIdpsParams) => http.put(`/api/v1/web/idps/${p
* 认证源插件默认配置
*/
export const getIdpsPluginsConfig = (id: string) => http.get(`/api/v1/web/idps/plugins/${id}/config-meta/`);

/**
* 新建本地账密认证源
*/
export const postLocalIdps = (params: NewLocalIdpsParams) => http.post('/api/v1/web/idps/local/', params);

/**
* 本地认证源详情
*/
export const getLocalIdps = (id: string) => http.get(`/api/v1/web/idps/local/${id}/`);

/**
* 更新本地认证源
*/
export const putLocalIdps = (params: NewLocalIdpsParams) => http.put(`/api/v1/web/idps/local/${params.id}/`, params);
18 changes: 18 additions & 0 deletions src/pages/src/http/types/authSourceFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
export interface NewIdpsParams {
name: string,
status: string,
plugin_id: string,
plugin_config: {},
data_source_match_rules?: {
Expand All @@ -28,6 +29,7 @@ export interface PatchIdpsParams {
export interface PutIdpsParams {
id: string,
name: string,
status: string,
plugin_config: {},
data_source_match_rules?: {
data_source_id: number,
Expand All @@ -37,3 +39,19 @@ export interface PutIdpsParams {
}[],
}[],
}

/**
* 新建本地认证源参数
*/
export interface NewLocalIdpsParams {
id?: string,
name: string,
status: string,
plugin_config: {
enable_password: boolean,
password_rule?: object,
password_initial?: object,
password_expire?: object,
login_limit?: object,
},
};
Loading

0 comments on commit 32c1bb7

Please sign in to comment.