Fall back to IdentityProvider component type if present (#21320)

Closes #15344
This commit is contained in:
Erik Jan de Wit 2023-07-11 14:41:52 +02:00 committed by GitHub
parent ac31c54fda
commit 982bac9db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,13 +28,24 @@ export default function AddIdentityProvider() {
const { providerId } = useParams<IdentityProviderCreateParams>();
const form = useForm<IdentityProviderRepresentation>();
const serverInfo = useServerInfo();
const providerInfo = useMemo(
() =>
serverInfo.componentTypes?.[
"org.keycloak.broker.social.SocialIdentityProvider"
]?.find((p) => p.id === providerId),
[serverInfo, providerId]
);
const providerInfo = useMemo(() => {
const namespaces = [
"org.keycloak.broker.social.SocialIdentityProvider",
"org.keycloak.broker.provider.IdentityProvider",
];
for (const namespace of namespaces) {
const social = serverInfo.componentTypes?.[namespace]?.find(
({ id }) => id === providerId
);
if (social) {
return social;
}
}
}, [serverInfo, providerId]);
const {
handleSubmit,
formState: { isDirty },