feat: completed reptile reviews

This commit is contained in:
=
2025-05-30 17:53:22 +00:00
committed by Akhil Mohan
parent d31d28666a
commit 86348eb434
5 changed files with 14 additions and 4 deletions
@@ -490,7 +490,7 @@ export const InternalCertificateAuthorityFns = ({
notBefore: notBeforeDate,
notAfter: notAfterDate,
keyUsages: selectedKeyUsages,
extendedKeyUsages: extendedKeyUsages as CertExtendedKeyUsage[],
extendedKeyUsages: selectedExtendedKeyUsages,
projectId: ca.projectId,
certificateTemplateId: certificateTemplate.id
},
@@ -120,6 +120,11 @@ export const pkiTemplatesServiceFactory = ({
subject(ProjectPermissionSub.CertificateTemplates, { name })
);
const existingTemplate = await pkiTemplatesDAL.findOne({ name, projectId: ca.projectId });
if (existingTemplate) {
throw new BadRequestError({ message: `Template with name ${name} already exists.` });
}
const newTemplate = await pkiTemplatesDAL.create({
caId,
name,
@@ -182,6 +187,11 @@ export const pkiTemplatesServiceFactory = ({
ProjectPermissionPkiTemplateActions.Edit,
subject(ProjectPermissionSub.CertificateTemplates, { name })
);
const existingTemplate = await pkiTemplatesDAL.findOne({ name, projectId });
if (existingTemplate && existingTemplate.id !== certTemplate.id) {
throw new BadRequestError({ message: `Template with name ${name} already exists.` });
}
}
const updatedTemplate = await pkiTemplatesDAL.updateById(certTemplate.id, {