From 228fbaf72ed31b5952b945741bbef32aa277506c Mon Sep 17 00:00:00 2001 From: Kartik <103111467+kartik-212004@users.noreply.github.com> Date: Tue, 11 Nov 2025 09:35:55 +0530 Subject: [PATCH] fix: skip email verification for reschedules and added test case (#24867) * fix: skip email verification for reschedules and added test case * used getNewBookingHandler helper instead of direct import in test --------- Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com> --- .../test/email-verification-booking.test.ts | 76 +++++++++++++++++++ .../lib/service/RegularBookingService.ts | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts index 2424d3dbea..1925ec45a1 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts @@ -341,5 +341,81 @@ describe("handleNewBooking - Email Verification", () => { }, timeout ); + + test( + "should allow rescheduling without email verification even when requiresBookerEmailVerification is true", + async () => { + const handleNewBooking = getNewBookingHandler(); + const { verifyCodeUnAuthenticated } = await import("@calcom/trpc/server/routers/viewer/auth/util"); + + const booker = getBooker({ + email: "booker@example.com", + name: "Booker", + }); + + const organizer = getOrganizer({ + name: "Organizer", + email: "organizer@example.com", + id: 101, + schedules: [TestData.schedules.IstWorkHours], + }); + + const scenarioData = getScenarioData({ + eventTypes: [ + { + id: 1, + slotInterval: 15, + length: 30, + users: [ + { + id: 101, + }, + ], + requiresBookerEmailVerification: true, + }, + ], + organizer, + bookings: [ + { + uid: "existing-booking-uid", + eventTypeId: 1, + userId: 101, + status: "ACCEPTED", + startTime: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), // tomorrow + endTime: new Date(Date.now() + 24 * 60 * 60 * 1000 + 30 * 60 * 1000).toISOString(), // tomorrow + 30 min + attendees: [ + { + email: booker.email, + name: booker.name, + timeZone: "Asia/Kolkata", + }, + ], + }, + ], + }); + + await createBookingScenario(scenarioData); + + const mockBookingData = getMockRequestDataForBooking({ + data: { + eventTypeId: 1, + rescheduleUid: "existing-booking-uid", + responses: { + email: booker.email, + name: booker.name, + location: { optionValue: "", value: "integrations:daily" }, + }, + }, + }); + + const result = await handleNewBooking({ bookingData: mockBookingData }); + + expect(result).toBeDefined(); + expect(result.uid).toBeDefined(); + + expect(verifyCodeUnAuthenticated).not.toHaveBeenCalled(); + }, + timeout + ); }); }); diff --git a/packages/features/bookings/lib/service/RegularBookingService.ts b/packages/features/bookings/lib/service/RegularBookingService.ts index 98ad810758..3b427d350c 100644 --- a/packages/features/bookings/lib/service/RegularBookingService.ts +++ b/packages/features/bookings/lib/service/RegularBookingService.ts @@ -559,7 +559,7 @@ async function handler( }); } - if (eventType.requiresBookerEmailVerification) { + if (eventType.requiresBookerEmailVerification && !rawBookingData.rescheduleUid) { const verificationCode = reqBody.verificationCode; if (!verificationCode) { throw new HttpError({