diff --git a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/CustomSCEPForm/CustomSCEPForm.tsx b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/CustomSCEPForm/CustomSCEPForm.tsx index e8956ff152..7717be5f42 100644 --- a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/CustomSCEPForm/CustomSCEPForm.tsx +++ b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/CustomSCEPForm/CustomSCEPForm.tsx @@ -102,7 +102,6 @@ const CustomSCEPForm = ({ value={challenge} onChange={onInputChange} parseTarget - placeholder="••••••••••••" helpText="Password to authenticate with a SCEP server." /> diff --git a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/EditCertAuthorityModal.tsx b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/EditCertAuthorityModal.tsx index 0bfb60d79b..47a22028a3 100644 --- a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/EditCertAuthorityModal.tsx +++ b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/EditCertAuthorityModal.tsx @@ -15,6 +15,7 @@ import { generateDefaultFormData, getErrorMessage, getCertificateAuthorityType, + updateFormData, } from "./helpers"; import DigicertForm from "../DigicertForm"; @@ -49,11 +50,7 @@ const EditCertAuthorityModal = ({ const onChangeForm = (update: { name: string; value: string }) => { setFormData((prevFormData) => { if (!prevFormData) return prevFormData; - - return { - ...prevFormData, - [update.name]: update.value, - }; + return updateFormData(certAuthority, prevFormData, update); }); }; diff --git a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/helpers.tsx b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/helpers.tsx index 44336fb228..ed6bd7daaf 100644 --- a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/helpers.tsx +++ b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/EditCertAuthorityModal/helpers.tsx @@ -48,6 +48,45 @@ export const generateDefaultFormData = ( }; }; +export const updateFormData = ( + certAuthority: ICertificateIntegration, + prevFormData: ICertFormData, + update: { name: string; value: string } +) => { + const newData = { ...prevFormData, [update.name]: update.value }; + + // for some inputs that change we want to reset one of the other inputs + // and force users to re-enter it. + if (isDigicertCertIntegration(certAuthority)) { + if ( + update.name === "name" || + update.name === "url" || + update.name === "profileId" + ) { + return { + ...newData, + apiToken: "", + }; + } + } else if (isNDESCertIntegration(certAuthority)) { + if (update.name === "adminURL" || update.name === "username") { + return { + ...newData, + password: "", + }; + } + } else if (isCustomSCEPCertIntegration(certAuthority)) { + if (update.name === "name" || update.name === "scepURL") { + return { + ...newData, + challenge: "", + }; + } + } + + return newData; +}; + export const getErrorMessage = (err: unknown) => { return `Couldn't edit certificate authority. ${getDisplayErrMessage(err)}`; }; diff --git a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/NDESForm/NDESForm.tsx b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/NDESForm/NDESForm.tsx index 7312f2334f..e7f0cc8d8b 100644 --- a/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/NDESForm/NDESForm.tsx +++ b/frontend/pages/admin/IntegrationsPage/cards/CertificateAuthorities/components/NDESForm/NDESForm.tsx @@ -92,7 +92,6 @@ const NDESForm = ({ type="password" onChange={onInputChange} parseTarget - placeholder="••••••••" blockAutoComplete helpText="The password required to log in to the SCEP admin page." />