misc: general improvements

This commit is contained in:
Sheen Capadngan
2025-05-29 23:36:31 +08:00
parent 1947989ca5
commit f7a9e13209

View File

@@ -137,6 +137,15 @@ export const pkiSubscriberServiceFactory = ({
}
}
const ca = await certificateAuthorityDAL.findById(caId);
if (!ca) {
throw new NotFoundError({ message: `CA with ID '${caId}' not found` });
}
if (ca.projectId !== projectId) {
throw new BadRequestError({ message: "CA does not belong to the project" });
}
const newSubscriber = await pkiSubscriberDAL.create({
caId,
projectId,
@@ -245,6 +254,17 @@ export const pkiSubscriberServiceFactory = ({
}
}
if (caId) {
const ca = await certificateAuthorityDAL.findById(caId);
if (!ca) {
throw new NotFoundError({ message: `CA with ID '${caId}' not found` });
}
if (ca.projectId !== projectId) {
throw new BadRequestError({ message: "CA does not belong to the project" });
}
}
const updatedSubscriber = await pkiSubscriberDAL.updateById(subscriber.id, {
caId,
name,