misc: added audit logs for certificate template

This commit is contained in:
Sheen Capadngan
2024-08-16 23:08:01 +08:00
parent 6fe1d77375
commit ed0463e3e4
7 changed files with 138 additions and 8 deletions
@@ -2,6 +2,7 @@ import ms from "ms";
import { z } from "zod";
import { CertificateTemplatesSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
@@ -49,6 +50,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
actorOrgId: req.permission.orgId
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
projectId: certificateTemplate.projectId,
event: {
type: EventType.GET_CERTIFICATE_TEMPLATE,
metadata: {
certificateTemplateId: certificateTemplate.id
}
}
});
return { certificateTemplate };
}
});
@@ -84,6 +96,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
...req.body
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
projectId: certificateTemplate.projectId,
event: {
type: EventType.CREATE_CERTIFICATE_TEMPLATE,
metadata: {
certificateTemplateId: certificateTemplate.id
}
}
});
return { certificateTemplate };
}
});
@@ -126,6 +149,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
actorOrgId: req.permission.orgId
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
projectId: certificateTemplate.projectId,
event: {
type: EventType.UPDATE_CERTIFICATE_TEMPLATE,
metadata: {
certificateTemplateId: certificateTemplate.id
}
}
});
return { certificateTemplate };
}
});
@@ -156,6 +190,17 @@ export const registerCertificateTemplateRouter = async (server: FastifyZodProvid
actorOrgId: req.permission.orgId
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
projectId: certificateTemplate.projectId,
event: {
type: EventType.DELETE_CERTIFICATE_TEMPLATE,
metadata: {
certificateTemplateId: certificateTemplate.id
}
}
});
return { certificateTemplate };
}
});