mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-12 19:29:15 +00:00
misc: addres LDAP config update and test issues
This commit is contained in:
@@ -151,10 +151,23 @@ export const useDeleteLDAPGroupMapping = () => {
|
||||
|
||||
export const useTestLDAPConnection = () => {
|
||||
return useMutation({
|
||||
mutationFn: async (ldapConfigId: string) => {
|
||||
const { data } = await apiRequest.post<boolean>(
|
||||
`/api/v1/ldap/config/${ldapConfigId}/test-connection`
|
||||
);
|
||||
mutationFn: async ({
|
||||
url,
|
||||
bindDN,
|
||||
bindPass,
|
||||
caCert
|
||||
}: {
|
||||
url: string;
|
||||
bindDN: string;
|
||||
bindPass: string;
|
||||
caCert: string;
|
||||
}) => {
|
||||
const { data } = await apiRequest.post<boolean>("/api/v1/ldap/config/test-connection", {
|
||||
url,
|
||||
bindDN,
|
||||
bindPass,
|
||||
caCert
|
||||
});
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -92,12 +92,7 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
||||
const watchUrl = watch("url");
|
||||
const watchBindDN = watch("bindDN");
|
||||
const watchBindPass = watch("bindPass");
|
||||
const watchSearchBase = watch("searchBase");
|
||||
const watchSearchFilter = watch("searchFilter");
|
||||
const watchGroupSearchBase = watch("groupSearchBase");
|
||||
const watchGroupSearchFilter = watch("groupSearchFilter");
|
||||
const watchCaCert = watch("caCert");
|
||||
const watchUniqueUserAttribute = watch("uniqueUserAttribute");
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
@@ -147,7 +142,6 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
||||
} else {
|
||||
await updateMutateAsync({
|
||||
organizationId: currentOrg.id,
|
||||
isActive: false,
|
||||
url,
|
||||
bindDN,
|
||||
bindPass,
|
||||
@@ -179,23 +173,13 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
|
||||
|
||||
const handleTestLDAPConnection = async () => {
|
||||
try {
|
||||
await onSSOModalSubmit({
|
||||
const result = await testLDAPConnection({
|
||||
url: watchUrl,
|
||||
bindDN: watchBindDN,
|
||||
bindPass: watchBindPass,
|
||||
searchBase: watchSearchBase,
|
||||
searchFilter: watchSearchFilter,
|
||||
groupSearchBase: watchGroupSearchBase,
|
||||
groupSearchFilter: watchGroupSearchFilter,
|
||||
uniqueUserAttribute: watchUniqueUserAttribute,
|
||||
caCert: watchCaCert,
|
||||
shouldCloseModal: false
|
||||
caCert: watchCaCert ?? ""
|
||||
});
|
||||
|
||||
if (!data) return;
|
||||
|
||||
const result = await testLDAPConnection(data.id);
|
||||
|
||||
if (!result) {
|
||||
createNotification({
|
||||
text: "Failed to test the LDAP connection: Bind operation was unsuccessful",
|
||||
|
||||
Reference in New Issue
Block a user