Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor: simplify authentication form submission logic across multiple identity sections

Victor Santoseba04e4278ba
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx
index 4ddcf964e7..7dc5d7f705 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx
@@ -137,45 +137,38 @@ export const IdentityAliCloudAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
- try {
- if (!identityId) return;
+ if (!identityId) return;
- if (data) {
- await updateMutateAsync({
- organizationId: orgId,
- allowedArns,
- identityId,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- organizationId: orgId,
- identityId,
- allowedArns,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
-
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ allowedArns,
+ identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId,
+ allowedArns,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthTemplateModal.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthTemplateModal.tsx
index 3bd4239829..6db81f19e7 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthTemplateModal.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthTemplateModal.tsx
@@ -103,56 +103,44 @@ export const IdentityAuthTemplateModal = ({ popUp, handlePopUpToggle }: Props) =
const selectedMethod = watch("method");
const onFormSubmit = async (data: FormData) => {
- try {
- if (isEdit && template) {
- await updateTemplate({
- templateId: template.id,
- organizationId: orgId,
- name: data.name,
- templateFields: {
- url: data.url,
- bindDN: data.bindDN,
- bindPass: data.bindPass,
- searchBase: data.searchBase,
- ldapCaCertificate: data.ldapCaCertificate
- }
- });
- createNotification({
- text: "Successfully updated auth template",
- type: "success"
- });
- } else {
- await createTemplate({
- organizationId: orgId,
- name: data.name,
- authMethod: data.method,
- templateFields: {
- url: data.url,
- bindDN: data.bindDN,
- bindPass: data.bindPass,
- searchBase: data.searchBase,
- ldapCaCertificate: data.ldapCaCertificate
- }
- });
- createNotification({
- text: "Successfully created auth template",
- type: "success"
- });
- }
-
- handlePopUpToggle(isEdit ? "editTemplate" : "createTemplate", false);
- reset();
- } catch (err) {
- console.error(err);
- const error = err as any;
- const text =
- error?.response?.data?.message ?? `Failed to ${isEdit ? "update" : "create"} auth template`;
-
+ if (isEdit && template) {
+ await updateTemplate({
+ templateId: template.id,
+ organizationId: orgId,
+ name: data.name,
+ templateFields: {
+ url: data.url,
+ bindDN: data.bindDN,
+ bindPass: data.bindPass,
+ searchBase: data.searchBase,
+ ldapCaCertificate: data.ldapCaCertificate
+ }
+ });
createNotification({
- text,
- type: "error"
+ text: "Successfully updated auth template",
+ type: "success"
+ });
+ } else {
+ await createTemplate({
+ organizationId: orgId,
+ name: data.name,
+ authMethod: data.method,
+ templateFields: {
+ url: data.url,
+ bindDN: data.bindDN,
+ bindPass: data.bindPass,
+ searchBase: data.searchBase,
+ ldapCaCertificate: data.ldapCaCertificate
+ }
+ });
+ createNotification({
+ text: "Successfully created auth template",
+ type: "success"
});
}
+
+ handlePopUpToggle(isEdit ? "editTemplate" : "createTemplate", false);
+ reset();
};
const handleClose = () => {
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
index 7e3292c181..db10667319 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
@@ -147,49 +147,42 @@ export const IdentityAwsAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
- try {
- if (!identityId) return;
+ if (!identityId) return;
- if (data) {
- await updateMutateAsync({
- organizationId: orgId,
- stsEndpoint,
- allowedPrincipalArns,
- allowedAccountIds,
- identityId,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- organizationId: orgId,
- identityId,
- stsEndpoint: stsEndpoint || "",
- allowedPrincipalArns: allowedPrincipalArns || "",
- allowedAccountIds: allowedAccountIds || "",
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
-
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ stsEndpoint,
+ allowedPrincipalArns,
+ allowedAccountIds,
+ identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId,
+ stsEndpoint: stsEndpoint || "",
+ allowedPrincipalArns: allowedPrincipalArns || "",
+ allowedAccountIds: allowedAccountIds || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
index 518d97e7b5..86f22c27e7 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
@@ -143,49 +143,42 @@ export const IdentityAzureAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
- try {
- if (!identityId) return;
+ if (!identityId) return;
- if (data) {
- await updateMutateAsync({
- organizationId: orgId,
- identityId,
- tenantId,
- resource,
- allowedServicePrincipalIds,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- organizationId: orgId,
- identityId,
- tenantId: tenantId || "",
- resource: resource || "",
- allowedServicePrincipalIds: allowedServicePrincipalIds || "",
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
-
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ identityId,
+ tenantId,
+ resource,
+ allowedServicePrincipalIds,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId,
+ tenantId: tenantId || "",
+ resource: resource || "",
+ allowedServicePrincipalIds: allowedServicePrincipalIds || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
index 7175e8b623..4d6ea63b27 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
@@ -152,51 +152,44 @@ export const IdentityGcpAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
- try {
- if (!identityId) return;
+ if (!identityId) return;
- if (data) {
- await updateMutateAsync({
- identityId,
- organizationId: orgId,
- type,
- allowedServiceAccounts,
- allowedProjects,
- allowedZones,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- identityId,
- organizationId: orgId,
- type,
- allowedServiceAccounts: allowedServiceAccounts || "",
- allowedProjects: allowedProjects || "",
- allowedZones: allowedZones || "",
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
-
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ identityId,
+ organizationId: orgId,
+ type,
+ allowedServiceAccounts,
+ allowedProjects,
+ allowedZones,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ identityId,
+ organizationId: orgId,
+ type,
+ allowedServiceAccounts: allowedServiceAccounts || "",
+ allowedProjects: allowedProjects || "",
+ allowedZones: allowedZones || "",
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
index f620458108..dfc0797908 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
@@ -217,61 +217,54 @@ export const IdentityJwtAuthForm = ({
boundClaims,
boundSubject
}: FormData) => {
- try {
- if (!identityId) {
- return;
- }
-
- if (data) {
- await updateMutateAsync({
- identityId,
- organizationId: orgId,
- configurationType,
- jwksUrl,
- jwksCaCert,
- publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
- boundIssuer,
- boundAudiences,
- boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
- boundSubject,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- identityId,
- configurationType,
- jwksUrl,
- jwksCaCert,
- publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
- boundIssuer,
- boundAudiences,
- boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
- boundSubject,
- organizationId: orgId,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
+ if (!identityId) {
+ return;
+ }
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ identityId,
+ organizationId: orgId,
+ configurationType,
+ jwksUrl,
+ jwksCaCert,
+ publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ boundSubject,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ identityId,
+ configurationType,
+ jwksUrl,
+ jwksCaCert,
+ publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ boundSubject,
+ organizationId: orgId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
index 9b8624990a..7fedf4a990 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
@@ -311,71 +311,64 @@ export const IdentityKubernetesAuthForm = ({
tokenReviewMode,
accessTokenTrustedIps
}: FormData) => {
- try {
- if (!identityId) return;
-
- if (data) {
- await updateMutateAsync({
- organizationId: orgId,
- ...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
- ? {
- kubernetesHost: kubernetesHost || ""
- }
- : {
- kubernetesHost: null
- }),
- tokenReviewerJwt: tokenReviewerJwt || null,
- allowedNames,
- allowedNamespaces,
- allowedAudience,
- caCert,
- identityId,
- gatewayId: gatewayId || null,
- tokenReviewMode,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- organizationId: orgId,
- identityId,
- ...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
- ? {
- kubernetesHost: kubernetesHost || ""
- }
- : {
- kubernetesHost: null
- }),
- tokenReviewerJwt: tokenReviewerJwt || undefined,
- allowedNames: allowedNames || "",
- allowedNamespaces: allowedNamespaces || "",
- allowedAudience: allowedAudience || "",
- gatewayId: gatewayId || null,
- caCert: caCert || "",
- tokenReviewMode,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
+ if (!identityId) return;
- handlePopUpToggle("identityAuthMethod", false);
-
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ ...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
+ ? {
+ kubernetesHost: kubernetesHost || ""
+ }
+ : {
+ kubernetesHost: null
+ }),
+ tokenReviewerJwt: tokenReviewerJwt || null,
+ allowedNames,
+ allowedNamespaces,
+ allowedAudience,
+ caCert,
+ identityId,
+ gatewayId: gatewayId || null,
+ tokenReviewMode,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId,
+ ...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
+ ? {
+ kubernetesHost: kubernetesHost || ""
+ }
+ : {
+ kubernetesHost: null
+ }),
+ tokenReviewerJwt: tokenReviewerJwt || undefined,
+ allowedNames: allowedNames || "",
+ allowedNamespaces: allowedNamespaces || "",
+ allowedAudience: allowedAudience || "",
+ gatewayId: gatewayId || null,
+ caCert: caCert || "",
+ tokenReviewMode,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
const tokenReviewMode = watch("tokenReviewMode");
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
index b2096fa06f..44b3a32de9 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
@@ -316,83 +316,76 @@ export const IdentityLdapAuthForm = ({
}, [subscription, handlePopUpOpen, handlePopUpToggle]);
const onFormSubmit = async (formData: FormData) => {
- try {
- if (!identityId) return;
-
- const {
- scope: submissionScope,
- templateId: submissionTemplateId,
- url: submissionUrl,
- bindDN: submissionBindDN,
- bindPass: submissionBindPass,
- searchBase: submissionSearchBase,
- searchFilter,
- ldapCaCertificate,
- allowedFields,
- accessTokenTTL,
- accessTokenMaxTTL,
- accessTokenNumUsesLimit,
- accessTokenTrustedIps,
- lockoutEnabled,
- lockoutThreshold,
- lockoutDurationValue,
- lockoutDurationUnit,
- lockoutCounterResetValue,
- lockoutCounterResetUnit
- } = formData;
-
- const lockoutDurationSeconds = ms(`${lockoutDurationValue}${lockoutDurationUnit}`) / 1000;
- const lockoutCounterResetSeconds =
- ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;
-
- const basePayload = {
- organizationId: orgId,
- identityId,
- searchFilter,
- ldapCaCertificate,
- allowedFields,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps,
- lockoutEnabled,
- lockoutThreshold: Number(lockoutThreshold),
- lockoutDurationSeconds,
- lockoutCounterResetSeconds
- };
-
- // Add scope-specific fields
- const payload =
- submissionScope === "template"
- ? { ...basePayload, templateId: submissionTemplateId }
- : {
- ...basePayload,
- url: submissionUrl,
- bindDN: submissionBindDN,
- bindPass: submissionBindPass,
- searchBase: submissionSearchBase
- };
+ if (!identityId) return;
+
+ const {
+ scope: submissionScope,
+ templateId: submissionTemplateId,
+ url: submissionUrl,
+ bindDN: submissionBindDN,
+ bindPass: submissionBindPass,
+ searchBase: submissionSearchBase,
+ searchFilter,
+ ldapCaCertificate,
+ allowedFields,
+ accessTokenTTL,
+ accessTokenMaxTTL,
+ accessTokenNumUsesLimit,
+ accessTokenTrustedIps,
+ lockoutEnabled,
+ lockoutThreshold,
+ lockoutDurationValue,
+ lockoutDurationUnit,
+ lockoutCounterResetValue,
+ lockoutCounterResetUnit
+ } = formData;
+
+ const lockoutDurationSeconds = ms(`${lockoutDurationValue}${lockoutDurationUnit}`) / 1000;
+ const lockoutCounterResetSeconds =
+ ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;
+
+ const basePayload = {
+ organizationId: orgId,
+ identityId,
+ searchFilter,
+ ldapCaCertificate,
+ allowedFields,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps,
+ lockoutEnabled,
+ lockoutThreshold: Number(lockoutThreshold),
+ lockoutDurationSeconds,
+ lockoutCounterResetSeconds
+ };
+
+ // Add scope-specific fields
+ const payload =
+ submissionScope === "template"
+ ? { ...basePayload, templateId: submissionTemplateId }
+ : {
+ ...basePayload,
+ url: submissionUrl,
+ bindDN: submissionBindDN,
+ bindPass: submissionBindPass,
+ searchBase: submissionSearchBase
+ };
- if (data) {
- await updateMutateAsync(payload);
- } else {
- await addMutateAsync(payload);
- }
+ if (data) {
+ await updateMutateAsync(payload);
+ } else {
+ await addMutateAsync(payload);
+ }
- handlePopUpToggle("identityAuthMethod", false);
+ handlePopUpToggle("identityAuthMethod", false);
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
- });
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
- });
- }
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLinkForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLinkForm.tsx
index b0977437b4..545aea5aa2 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLinkForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLinkForm.tsx
@@ -42,31 +42,20 @@ export const IdentityLinkForm = ({ onClose }: Props) => {
});
const onFormSubmit = async ({ identity, role }: FormData) => {
- try {
- await createMutateAsync({
- identityId: identity.id,
- roles: [{ role: role.slug, isTemporary: false }]
- });
- createNotification({
- text: "Successfully linked identity",
- type: "success"
- });
- navigate({
- to: "/organization/identities/$identityId",
- params: {
- identityId: identity.id
- }
- });
- } catch (err) {
- console.error(err);
- const error = err as any;
- const text = error?.response?.data?.message ?? "Failed to link identity";
-
- createNotification({
- text,
- type: "error"
- });
- }
+ await createMutateAsync({
+ identityId: identity.id,
+ roles: [{ role: role.slug, isTemporary: false }]
+ });
+ createNotification({
+ text: "Successfully linked identity",
+ type: "success"
+ });
+ navigate({
+ to: "/organization/identities/$identityId",
+ params: {
+ identityId: identity.id
+ }
+ });
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
index dacbba4281..09e779fa99 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal.tsx
@@ -108,81 +108,68 @@ export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [popUp?.identity?.data, roles]);
const onFormSubmit = async ({ name, role, metadata, hasDeleteProtection }: FormData) => {
- try {
- const identity = popUp?.identity?.data as {
- identityId: string;
- name: string;
- role: string;
- hasDeleteProtection: boolean;
- orgId: string;
- };
-
- if (identity) {
- // update
-
- await updateMutateAsync({
- identityId: identity.identityId,
- name,
- role: role.slug || undefined,
- hasDeleteProtection,
- organizationId: orgId,
- metadata
- });
-
- handlePopUpToggle("identity", false);
- } else {
- // create
+ const identity = popUp?.identity?.data as {
+ identityId: string;
+ name: string;
+ role: string;
+ hasDeleteProtection: boolean;
+ orgId: string;
+ };
- const { id: createdId } = await createMutateAsync({
- name,
- role: role.slug || undefined,
- hasDeleteProtection,
- organizationId: orgId,
- metadata
- });
+ if (identity) {
+ // update
- await addMutateAsync({
- organizationId: orgId,
- identityId: createdId,
- clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
- accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
- accessTokenTTL: 2592000,
- accessTokenMaxTTL: 2592000,
- accessTokenNumUsesLimit: 0,
- accessTokenPeriod: 0,
- lockoutEnabled: true,
- lockoutThreshold: 3,
- lockoutDurationSeconds: 300,
- lockoutCounterResetSeconds: 30
- });
+ await updateMutateAsync({
+ identityId: identity.identityId,
+ name,
+ role: role.slug || undefined,
+ hasDeleteProtection,
+ organizationId: orgId,
+ metadata
+ });
- handlePopUpToggle("identity", false);
- navigate({
- to: "/organization/identities/$identityId",
- params: {
- identityId: createdId
- }
- });
- }
+ handlePopUpToggle("identity", false);
+ } else {
+ // create
- createNotification({
- text: `Successfully ${popUp?.identity?.data ? "updated" : "created"} identity`,
- type: "success"
+ const { id: createdId } = await createMutateAsync({
+ name,
+ role: role.slug || undefined,
+ hasDeleteProtection,
+ organizationId: orgId,
+ metadata
});
- reset();
- } catch (err) {
- console.error(err);
- const error = err as any;
- const text =
- error?.response?.data?.message ??
- `Failed to ${popUp?.identity?.data ? "update" : "create"} identity`;
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId: createdId,
+ clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
+ accessTokenTTL: 2592000,
+ accessTokenMaxTTL: 2592000,
+ accessTokenNumUsesLimit: 0,
+ accessTokenPeriod: 0,
+ lockoutEnabled: true,
+ lockoutThreshold: 3,
+ lockoutDurationSeconds: 300,
+ lockoutCounterResetSeconds: 30
+ });
- createNotification({
- text,
- type: "error"
+ handlePopUpToggle("identity", false);
+ navigate({
+ to: "/organization/identities/$identityId",
+ params: {
+ identityId: createdId
+ }
});
}
+
+ createNotification({
+ text: `Successfully ${popUp?.identity?.data ? "updated" : "created"} identity`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx
index 5e33c71bbe..ffbde6f7a0 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx
@@ -149,47 +149,40 @@ export const IdentityOciAuthForm = ({
accessTokenNumUsesLimit,
accessTokenTrustedIps
}: FormData) => {
- try {
- if (!identityId) return;
+ if (!identityId) return;
- if (data) {
- await updateMutateAsync({
- organizationId: orgId,
- tenancyOcid,
- allowedUsernames,
- identityId,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- organizationId: orgId,
- identityId,
- tenancyOcid,
- allowedUsernames: allowedUsernames || undefined,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
-
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ organizationId: orgId,
+ tenancyOcid,
+ allowedUsernames,
+ identityId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ organizationId: orgId,
+ identityId,
+ tenancyOcid,
+ allowedUsernames: allowedUsernames || undefined,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
index 15fbc4b724..0ada2e663b 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
@@ -201,63 +201,56 @@ export const IdentityOidcAuthForm = ({
claimMetadataMapping,
boundSubject
}: FormData) => {
- try {
- if (!identityId) {
- return;
- }
-
- if (data) {
- await updateMutateAsync({
- identityId,
- organizationId: orgId,
- oidcDiscoveryUrl,
- caCert,
- boundIssuer,
- boundAudiences,
- boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
- claimMetadataMapping: claimMetadataMapping
- ? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
- : undefined,
- boundSubject,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- } else {
- await addMutateAsync({
- identityId,
- oidcDiscoveryUrl,
- caCert,
- boundIssuer,
- boundAudiences,
- boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
- claimMetadataMapping: claimMetadataMapping
- ? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
- : undefined,
- boundSubject,
- organizationId: orgId,
- accessTokenTTL: Number(accessTokenTTL),
- accessTokenMaxTTL: Number(accessTokenMaxTTL),
- accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
- accessTokenTrustedIps
- });
- }
-
- handlePopUpToggle("identityAuthMethod", false);
+ if (!identityId) {
+ return;
+ }
- createNotification({
- text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
- type: "success"
+ if (data) {
+ await updateMutateAsync({
+ identityId,
+ organizationId: orgId,
+ oidcDiscoveryUrl,
+ caCert,
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ claimMetadataMapping: claimMetadataMapping
+ ? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
+ : undefined,
+ boundSubject,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
-
- reset();
- } catch {
- createNotification({
- text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
- type: "error"
+ } else {
+ await addMutateAsync({
+ identityId,
+ oidcDiscoveryUrl,
+ caCert,
+ boundIssuer,
+ boundAudiences,
+ boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
+ claimMetadataMapping: claimMetadataMapping
+ ? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
+ : undefined,
+ boundSubject,
+ organizationId: orgId,
+ accessTokenTTL: Number(accessTokenTTL),
+ accessTokenMaxTTL: Number(accessTokenMaxTTL),
+ accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
+ accessTokenTrustedIps
});
}
+
+ handlePopUpToggle("identityAuthMethod", false);
+
+ createNotification({
+ text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
+ type: "success"
+ });
+
+ reset();
};
return (