Skip to content

Scheduling infrastructure for absolutely everyone.

fix: verification code perf (#27631)

sean-brydon1a0bf47bc56c
diff --git a/packages/trpc/server/routers/viewer/workflows/sendVerificationCode.handler.ts b/packages/trpc/server/routers/viewer/workflows/sendVerificationCode.handler.ts
index f5a2826510d..0badf1c0573 100644
--- a/packages/trpc/server/routers/viewer/workflows/sendVerificationCode.handler.ts
+++ b/packages/trpc/server/routers/viewer/workflows/sendVerificationCode.handler.ts
@@ -1,5 +1,6 @@
import { CreditsRepository } from "@calcom/features/credits/repositories/CreditsRepository";
import { sendVerificationCode } from "@calcom/features/ee/workflows/lib/reminders/verifyPhoneNumber";
+import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
@@ -34,6 +35,11 @@ export const sendVerificationCodeHandler = async ({ ctx, input }: SendVerificati
throw new TRPCError({ code: "UNAUTHORIZED" });
}
+ await checkRateLimitAndThrowError({
+ identifier: `sendVerificationCode:${user.id}`,
+ rateLimitingType: "core",
+ });
+
const { phoneNumber } = input;
return sendVerificationCode(phoneNumber);
};