chore: disabled account enforcement (#2882)

This commit is contained in:
Lucas Smith
2026-05-28 21:19:13 +09:00
committed by GitHub
parent 7e8da85bd8
commit a84da2f2c7
8 changed files with 112 additions and 15 deletions
@@ -30,6 +30,7 @@ import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
import { assertOrgEmailSendAllowed } from '../email/assert-org-email-send-allowed';
import { getEmailContext } from '../email/get-email-context';
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
import { assertUserNotDisabled } from '../user/assert-user-not-disabled';
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
export type ResendDocumentOptions = {
@@ -49,9 +50,14 @@ export const resendDocument = async ({ id, userId, recipients, teamId, requestMe
id: true,
email: true,
name: true,
disabled: true,
},
});
// Refuse to resend on behalf of a disabled account. Guards
// document.redistribute / envelope.redistribute and the API v1 equivalent.
assertUserNotDisabled(user);
const { envelopeWhereInput } = await getEnvelopeWhereInput({
id,
type: EnvelopeType.DOCUMENT,
@@ -39,6 +39,7 @@ import { toCheckboxCustomText, toRadioCustomText } from '../../utils/fields';
import { getRecipientsWithMissingFields, isRecipientEmailValidForSending } from '../../utils/recipients';
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
import { insertFormValuesInPdf } from '../pdf/insert-form-values-in-pdf';
import { assertUserNotDisabledById } from '../user/assert-user-not-disabled';
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
export type SendDocumentOptions = {
@@ -50,6 +51,11 @@ export type SendDocumentOptions = {
};
export const sendDocument = async ({ id, userId, teamId, sendEmail, requestMetadata }: SendDocumentOptions) => {
// Refuse to send on behalf of a disabled account. Guards distribute /
// redistribute / template-use routes, the bulk-send job, and direct
// templates that auto-send on creation.
await assertUserNotDisabledById({ userId });
const { envelopeWhereInput } = await getEnvelopeWhereInput({
id,
type: EnvelopeType.DOCUMENT,