Merge branch 'main' into feat/delete-archive

This commit is contained in:
Lucas Smith
2024-08-21 11:44:05 +10:00
committed by GitHub
124 changed files with 2129 additions and 772 deletions

View File

@ -30,6 +30,7 @@ import {
ZCreateDocumentMutationSchema,
ZDeleteDraftDocumentMutationSchema as ZDeleteDocumentMutationSchema,
ZDownloadAuditLogsMutationSchema,
ZDownloadCertificateMutationSchema,
ZFindDocumentAuditLogsQuerySchema,
ZGetDocumentByIdQuerySchema,
ZGetDocumentByTokenQuerySchema,
@ -441,7 +442,14 @@ export const documentRouter = router({
id: documentId,
userId: ctx.user.id,
teamId,
});
}).catch(() => null);
if (!document || (teamId && document.teamId !== teamId)) {
throw new TRPCError({
code: 'FORBIDDEN',
message: 'You do not have access to this document.',
});
}
const encrypted = encryptSecondaryData({
data: document.id.toString(),
@ -463,7 +471,7 @@ export const documentRouter = router({
}),
downloadCertificate: authenticatedProcedure
.input(ZDownloadAuditLogsMutationSchema)
.input(ZDownloadCertificateMutationSchema)
.mutation(async ({ input, ctx }) => {
try {
const { documentId, teamId } = input;