mirror of
https://github.com/documenso/documenso.git
synced 2025-11-21 12:11:29 +10:00
chore: disable next step on backend for signers without signature field
This commit is contained in:
@ -72,6 +72,22 @@ export const setFieldsForDocument = async ({
|
||||
});
|
||||
}
|
||||
|
||||
// Check that every signer has a signature field
|
||||
const signers = document.recipients.filter((recipient) => recipient.role === 'SIGNER');
|
||||
const hasEverySignerSignature = signers.every((signer) =>
|
||||
fields.some(
|
||||
(field) =>
|
||||
(field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) &&
|
||||
field.recipientId === signer.id,
|
||||
),
|
||||
);
|
||||
|
||||
if (!hasEverySignerSignature) {
|
||||
throw new AppError(AppErrorCode.INVALID_REQUEST, {
|
||||
message: 'Every signer must have at least one signature field',
|
||||
});
|
||||
}
|
||||
|
||||
if (document.completedAt) {
|
||||
throw new AppError(AppErrorCode.INVALID_REQUEST, {
|
||||
message: 'Document already complete',
|
||||
|
||||
Reference in New Issue
Block a user