Skip to content

Commit 228fbaf

Browse files
fix: skip email verification for reschedules and added test case (calcom#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>
1 parent 0c53717 commit 228fbaf

2 files changed

Lines changed: 77 additions & 1 deletion

File tree

packages/features/bookings/lib/handleNewBooking/test/email-verification-booking.test.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,5 +341,81 @@ describe("handleNewBooking - Email Verification", () => {
341341
},
342342
timeout
343343
);
344+
345+
test(
346+
"should allow rescheduling without email verification even when requiresBookerEmailVerification is true",
347+
async () => {
348+
const handleNewBooking = getNewBookingHandler();
349+
const { verifyCodeUnAuthenticated } = await import("@calcom/trpc/server/routers/viewer/auth/util");
350+
351+
const booker = getBooker({
352+
email: "booker@example.com",
353+
name: "Booker",
354+
});
355+
356+
const organizer = getOrganizer({
357+
name: "Organizer",
358+
email: "organizer@example.com",
359+
id: 101,
360+
schedules: [TestData.schedules.IstWorkHours],
361+
});
362+
363+
const scenarioData = getScenarioData({
364+
eventTypes: [
365+
{
366+
id: 1,
367+
slotInterval: 15,
368+
length: 30,
369+
users: [
370+
{
371+
id: 101,
372+
},
373+
],
374+
requiresBookerEmailVerification: true,
375+
},
376+
],
377+
organizer,
378+
bookings: [
379+
{
380+
uid: "existing-booking-uid",
381+
eventTypeId: 1,
382+
userId: 101,
383+
status: "ACCEPTED",
384+
startTime: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), // tomorrow
385+
endTime: new Date(Date.now() + 24 * 60 * 60 * 1000 + 30 * 60 * 1000).toISOString(), // tomorrow + 30 min
386+
attendees: [
387+
{
388+
email: booker.email,
389+
name: booker.name,
390+
timeZone: "Asia/Kolkata",
391+
},
392+
],
393+
},
394+
],
395+
});
396+
397+
await createBookingScenario(scenarioData);
398+
399+
const mockBookingData = getMockRequestDataForBooking({
400+
data: {
401+
eventTypeId: 1,
402+
rescheduleUid: "existing-booking-uid",
403+
responses: {
404+
email: booker.email,
405+
name: booker.name,
406+
location: { optionValue: "", value: "integrations:daily" },
407+
},
408+
},
409+
});
410+
411+
const result = await handleNewBooking({ bookingData: mockBookingData });
412+
413+
expect(result).toBeDefined();
414+
expect(result.uid).toBeDefined();
415+
416+
expect(verifyCodeUnAuthenticated).not.toHaveBeenCalled();
417+
},
418+
timeout
419+
);
344420
});
345421
});

packages/features/bookings/lib/service/RegularBookingService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ async function handler(
559559
});
560560
}
561561

562-
if (eventType.requiresBookerEmailVerification) {
562+
if (eventType.requiresBookerEmailVerification && !rawBookingData.rescheduleUid) {
563563
const verificationCode = reqBody.verificationCode;
564564
if (!verificationCode) {
565565
throw new HttpError({

0 commit comments

Comments
 (0)