Commit 64297f0
feat: add user-specific email verification setting (calcom#24298)
* feat: add user-specific email verification setting
Add requiresBookerEmailVerification boolean field to User model that allows
users to protect their email from impersonation during bookings.
When enabled, anyone attempting to book using the protected user's email
address (as booker or guest) must complete email verification and be logged
in as that email owner.
Key changes:
- Add requiresBookerEmailVerification field to User schema
- Create settings toggle in /settings/my-account/general
- Update checkIfBookerEmailIsBlocked to check booker's account setting
- Update guest filtering in handleNewBooking and addGuests handlers
- Add i18n translations for new setting
- Check both primary and verified secondary emails
Additional fixes:
- Replace 'any' types with proper Prisma and zod types in user.ts
- Fix member role type in sessionMiddleware.ts
- Fix avatar URL generation bug in sessionMiddleware.ts
These type fixes were necessary to resolve pre-commit lint warnings that
were blocking the commit.
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: address PR review comments
- Remove unrelated Watchlist index drops from migration
- Add missing Watchlist indexes to schema.prisma to fix drift
- Refactor checkIfBookerEmailIsBlocked to throw ErrorWithCode
- Move HttpError handling to handleNewBooking caller layer
Addresses review comments on PR calcom#24298
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* refactor: move Prisma queries to UserRepository and remove unrelated Watchlist changes
- Add findByEmailWithEmailVerificationSetting method to UserRepository
- Add findManyByEmailsWithEmailVerificationSettings method to UserRepository
- Refactor checkIfUserEmailVerificationRequired handler to use UserRepository
- Refactor addGuests handler to use UserRepository
- Remove unrelated Watchlist schema indices (organizationId/isGlobal, source)
- Remove unrelated WatchlistAudit unique constraint on id
Addresses review comments on PR calcom#24298
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: better error codes + use repo
* Updated db query with manully written one using UNION (calcom#24430)
* fix: resolve usage of deprecated secondary email in return value
* fix: type errors from refactors
* fix: address CodeRabbit PR review comments
- Add NOT NULL constraint to requiresBookerEmailVerification migration
- Dedupe guest input by base email to handle plus-addressing correctly
- Compare attendees by base email instead of raw strings
- Send emails only to filtered uniqueGuests (not all guests)
- Improve error logging with actual error details
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: indices added by mistake
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
* chore: update label of setting
* fix: return matched email for guests
* chore: remove whitespace
* test: add comprehensive email verification tests
- Add 9 test scenarios covering user email verification setting
- Test main booker verification (logged in/out, with/without code)
- Test secondary email verification as main booker and guest
- Test guest filtering when verification is required
- Test plus-addressed email handling
- Test multiple guests with mixed verification requirements
- Test invalid verification code error handling
- Update bookingScenario helper to support requiresBookerEmailVerification and secondaryEmails
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
* fix: correct guest placement in test mock data
Move guests array from top-level booking data into responses object
to match expected structure in getBookingData.ts which looks for
responses.guests (line 74).
Fixes three failing tests:
- should filter out guest that requires verification
- should filter out secondary email with verification when added as guest
- should filter only guests requiring verification from multiple guests
Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Rodrigo Ehlers <rodrigoehlers@outlook.com>
Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com>
Co-authored-by: Rodrigo Ehlers <rodrigo@chatbyte.ai>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>1 parent 9fe5ff7 commit 64297f0
16 files changed
Lines changed: 1065 additions & 53 deletions
File tree
- apps/web
- modules/settings/my-account
- public/static/locales/en
- test/utils/bookingScenario
- packages
- features
- bookings/lib
- handleNewBooking
- test
- users/repositories
- lib
- prisma
- migrations/20251006111422_add_requires_booker_email_verification
- trpc/server
- middlewares
- routers
- publicViewer
- viewer
- bookings
- me
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
353 | 356 | | |
354 | 357 | | |
355 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
356 | 372 | | |
357 | 373 | | |
358 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3626 | 3626 | | |
3627 | 3627 | | |
3628 | 3628 | | |
| 3629 | + | |
| 3630 | + | |
3629 | 3631 | | |
3630 | 3632 | | |
3631 | 3633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| |||
834 | 836 | | |
835 | 837 | | |
836 | 838 | | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
837 | 854 | | |
838 | 855 | | |
839 | 856 | | |
| |||
845 | 862 | | |
846 | 863 | | |
847 | 864 | | |
| 865 | + | |
848 | 866 | | |
849 | 867 | | |
850 | 868 | | |
| |||
1554 | 1572 | | |
1555 | 1573 | | |
1556 | 1574 | | |
| 1575 | + | |
| 1576 | + | |
1557 | 1577 | | |
1558 | 1578 | | |
1559 | 1579 | | |
| |||
1572 | 1592 | | |
1573 | 1593 | | |
1574 | 1594 | | |
| 1595 | + | |
| 1596 | + | |
1575 | 1597 | | |
1576 | 1598 | | |
1577 | 1599 | | |
| |||
1594 | 1616 | | |
1595 | 1617 | | |
1596 | 1618 | | |
| 1619 | + | |
| 1620 | + | |
1597 | 1621 | | |
1598 | 1622 | | |
1599 | 1623 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
493 | 494 | | |
494 | 495 | | |
495 | 496 | | |
| |||
545 | 546 | | |
546 | 547 | | |
547 | 548 | | |
548 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
549 | 561 | | |
550 | 562 | | |
551 | 563 | | |
| |||
1196 | 1208 | | |
1197 | 1209 | | |
1198 | 1210 | | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1199 | 1222 | | |
1200 | 1223 | | |
1201 | 1224 | | |
| 1225 | + | |
1202 | 1226 | | |
1203 | 1227 | | |
1204 | 1228 | | |
1205 | 1229 | | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1206 | 1236 | | |
1207 | 1237 | | |
1208 | 1238 | | |
| |||
Lines changed: 41 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | | - | |
3 | 4 | | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
17 | | - | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
52 | 61 | | |
53 | | - | |
| 62 | + | |
54 | 63 | | |
55 | 64 | | |
56 | 65 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
61 | 91 | | |
62 | 92 | | |
0 commit comments