mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 06:48:54 +00:00
dont allow cert to have same name if the same cert type in the UI (#33343)
fixes #33246 This adds logic on the UI to show an error if a cert with the same types tries to create a new cert with an existing name
This commit is contained in:
parent
11fa6ff313
commit
c99aa8cbff
6 changed files with 23 additions and 14 deletions
|
|
@ -147,12 +147,14 @@ const CertificateAuthorities = () => {
|
|||
onExit={onAddedNewCertAuthority}
|
||||
/>
|
||||
)}
|
||||
{showEditCertAuthorityModal && selectedCertAuthority && (
|
||||
<EditCertAuthorityModal
|
||||
certAuthority={selectedCertAuthority}
|
||||
onExit={onEditedCertAuthority}
|
||||
/>
|
||||
)}
|
||||
{showEditCertAuthorityModal &&
|
||||
selectedCertAuthority &&
|
||||
certAuthorities && (
|
||||
<EditCertAuthorityModal
|
||||
certAuthority={selectedCertAuthority}
|
||||
onExit={onEditedCertAuthority}
|
||||
/>
|
||||
)}
|
||||
{showDeleteCertAuthorityModal && selectedCertAuthority && (
|
||||
<DeleteCertificateAuthorityModal
|
||||
certAuthority={selectedCertAuthority}
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ const AddCertAuthorityModal = ({
|
|||
return (
|
||||
<DigicertForm
|
||||
formData={digicertFormData}
|
||||
certAuthorities={certAuthorities}
|
||||
submitBtnText={submitBtnText}
|
||||
isSubmitting={isAdding}
|
||||
onChange={onChangeForm}
|
||||
|
|
@ -176,6 +177,7 @@ const AddCertAuthorityModal = ({
|
|||
return (
|
||||
<HydrantForm
|
||||
formData={hydrantFormData}
|
||||
certAuthorities={certAuthorities}
|
||||
submitBtnText={submitBtnText}
|
||||
isSubmitting={isAdding}
|
||||
onChange={onChangeForm}
|
||||
|
|
@ -198,6 +200,7 @@ const AddCertAuthorityModal = ({
|
|||
return (
|
||||
<CustomSCEPForm
|
||||
formData={customSCEPFormData}
|
||||
certAuthorities={certAuthorities}
|
||||
submitBtnText={submitBtnText}
|
||||
isSubmitting={isAdding}
|
||||
onChange={onChangeForm}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type IFormValidations = Record<
|
|||
>;
|
||||
|
||||
export const generateFormValidations = (
|
||||
customSCEPIntegrations: ICertificateAuthorityPartial[],
|
||||
certAuthorities: ICertificateAuthorityPartial[],
|
||||
isEditing: boolean
|
||||
) => {
|
||||
const FORM_VALIDATIONS: IFormValidations = {
|
||||
|
|
@ -54,8 +54,10 @@ export const generateFormValidations = (
|
|||
isValid: (formData: ICustomSCEPFormData) => {
|
||||
return (
|
||||
isEditing ||
|
||||
customSCEPIntegrations.find(
|
||||
(cert) => cert.name === formData.name
|
||||
certAuthorities.find(
|
||||
(cert) =>
|
||||
cert.type === "custom_scep_proxy" &&
|
||||
cert.name === formData.name
|
||||
) === undefined
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@ export const generateFormValidations = (
|
|||
isValid: (formData: IDigicertFormData) => {
|
||||
return (
|
||||
isEditing ||
|
||||
certAuthorities.find((cert) => cert.name === formData.name) ===
|
||||
undefined
|
||||
certAuthorities.find(
|
||||
(cert) =>
|
||||
cert.type === "digicert" && cert.name === formData.name
|
||||
) === undefined
|
||||
);
|
||||
},
|
||||
message: "Name is already used by another DigiCert CA.",
|
||||
|
|
|
|||
|
|
@ -59,8 +59,9 @@ export const generateFormValidations = (
|
|||
isValid: (formData: IHydrantFormData) => {
|
||||
return (
|
||||
isEditing ||
|
||||
certAuthorities.find((cert) => cert.name === formData.name) ===
|
||||
undefined
|
||||
certAuthorities.find(
|
||||
(cert) => cert.type === "hydrant" && cert.name === formData.name
|
||||
) === undefined
|
||||
);
|
||||
},
|
||||
message: "Name is already used by another Hydrant CA.",
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ const NDESForm = ({
|
|||
formData,
|
||||
submitBtnText,
|
||||
isSubmitting,
|
||||
isEditing = false,
|
||||
isDirty = true,
|
||||
onChange,
|
||||
onSubmit,
|
||||
|
|
|
|||
Loading…
Reference in a new issue