OIDC 协议页面配置优化

pull/81/MERGE
awenes 2024-08-17 13:42:48 +08:00
parent deb27bace3
commit a19aa9303a
1 changed files with 121 additions and 101 deletions

View File

@ -75,7 +75,6 @@ export default (props: { app: GetApp | Record<string, any> }) => {
const { id, template } = app;
const [form] = Form.useForm();
const [protocolEndpoint, setProtocolEndpoint] = useState<Record<string, string>>({});
const [idTokenCustomClaimsTableForm] = Form.useForm();
const [loading, setLoading] = useState<boolean>(true);
useMount(async () => {
@ -127,8 +126,6 @@ export default (props: { app: GetApp | Record<string, any> }) => {
form={form}
scrollToFirstError
onFinish={async (values) => {
//校验扩展字段
await idTokenCustomClaimsTableForm.validateFields();
setLoading(true);
const { success } = await saveAppConfig({
id,
@ -269,9 +266,17 @@ export default (props: { app: GetApp | Record<string, any> }) => {
);
}}
</ProFormDependency>
<ProFormDependency name={['authGrantTypes']}>
{({ authGrantTypes }) => {
const required =
authGrantTypes?.includes('implicit') ||
authGrantTypes?.includes('authorization_code');
return (
<Form.List
name="redirectUris"
rules={[
rules={
required
? [
{
validator: async (_, value) => {
if (value && value.length > 0) {
@ -286,14 +291,15 @@ export default (props: { app: GetApp | Record<string, any> }) => {
);
},
},
]}
]
: []
}
>
{(fields, { add, remove }, { errors }) => (
<>
{fields.map(({ key, name, ...restField }, index) => (
<Form.Item
{...(index === 0 ? layout : formItemLayoutWithOutLabel)}
required={true}
key={key}
label={
index === 0
@ -314,7 +320,9 @@ export default (props: { app: GetApp | Record<string, any> }) => {
{...restField}
name={[name]}
validateTrigger={['onChange', 'onBlur']}
rules={[
rules={
required
? [
{
required: true,
message: intl.formatMessage({
@ -327,7 +335,16 @@ export default (props: { app: GetApp | Record<string, any> }) => {
id: 'pages.app.config.detail.protocol_config.oidc.redirect_uris.rule.1.message',
}),
},
]}
]
: [
{
type: 'url',
message: intl.formatMessage({
id: 'pages.app.config.detail.protocol_config.oidc.redirect_uris.rule.1.message',
}),
},
]
}
noStyle
>
<Input
@ -342,7 +359,7 @@ export default (props: { app: GetApp | Record<string, any> }) => {
))}
<Form.Item
{...(fields.length === 0 ? layout : formItemLayoutWithOutLabel)}
required={true}
required={required}
label={
fields.length === 0
? intl.formatMessage({
@ -367,6 +384,9 @@ export default (props: { app: GetApp | Record<string, any> }) => {
</>
)}
</Form.List>
);
}}
</ProFormDependency>
<Form.List name="postLogoutRedirectUris">
{(fields, { add, remove }, {}) => (
<>