Conversation
…erification ordering, and unlock flow Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
Contributor
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts">
<violation number="1" location="apps/web/app/api/auth/signup/handlers/calcomSignupHandler.ts:320">
P2: The new unconditional verification call also runs for token-based invite signups, even though those users are already marked `emailVerified`. This can create unnecessary verification tokens/emails and confuse invited users. Consider skipping the call when `foundToken` is present.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ Pushed commit |
Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
Contributor
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/features/watchlist/lib/service/AdminWatchlistOperationsService.ts">
<violation number="1" location="packages/features/watchlist/lib/service/AdminWatchlistOperationsService.ts:224">
P1: Rule violated: **Avoid Logging Sensitive Information**
Remove the email address from error logging to avoid exposing PII in logs (Rule: Avoid Logging Sensitive Information).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/features/watchlist/lib/service/AdminWatchlistOperationsService.ts
Outdated
Show resolved
Hide resolved
Contributor
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ Pushed commit |
Co-Authored-By: ali@cal.com <alishahbaz7@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes three bugs in the signup watchlist review feature introduced in #27912, and adds auto-unlock behavior when SIGNUP-source watchlist entries are removed.
Bug Fixes
GlobalWatchlistRepository.deleteEntrymissingawait— Prisma queries are lazy; withoutawait, the delete was silently never executed. This caused watchlist entries to persist even after an admin unlocked a user.Email verification race condition —
sendEmailVerificationwas called (fire-and-forget) BEFORE the watchlist check added the email to the blocklist. By the timesendEmailVerificationran its internal watchlist check, the email was already blocked, so no verification token was ever created. Fixed by movingsendEmailVerificationto AFTER the watchlist early-return path, so it only runs for non-watchlisted signups.No verification email on unlock — After an admin unlocks a user and removes them from the watchlist, the user had no way to verify their email. Now
sendEmailVerificationis called after unlock inlockUserAccount.handler.ts.Additionally,
sendEmailVerificationis now scoped to non-invite signups (!checkoutSessionId && !token) to prevent redundant verification emails for team invite users who already haveemailVerifiedset.New: Auto-unlock on SIGNUP watchlist entry removal
When a watchlist entry with
source: SIGNUPandtype: EMAILis deleted (single or bulk) viaAdminWatchlistOperationsService, the associated user is automatically:UserRepository.unlockByEmail)This works for both
deleteWatchlistEntry(single) andbulkDeleteWatchlistEntries(bulk). Errors in the unlock/email flow are caught and logged — they do not block the deletion itself.Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
signup-watchlist-reviewfeature flag in the databasesource: 'SIGNUP'(not'MANUAL')Human Review Checklist
sendEmailVerificationin unlock handler isawaited (lockUserAccount.handler.ts:45): Unlike the fire-and-forget pattern in the signup handler, the unlock handler awaits the call. If the email service fails, the unlock response will also fail. Confirm this is acceptable or if it should be fire-and-forget.deleteEntryawait fix (GlobalWatchlistRepository.ts:166): Confirm the missingawaitwas indeed the root cause of watchlist entries not being deleted on unlock.Order of operations in signup handler (
calcomSignupHandler.ts:320-326): The watchlist check + early return now happens BEFOREsendEmailVerification. For the watchlist review path, the handler returns at line 317, sosendEmailVerificationat line 320 is never reached — which is the correct behavior.!tokenguard onsendEmailVerification(calcomSignupHandler.ts:320): Team invite signups (token flow) already setemailVerifieddirectly, so they skip verification. Confirm this guard is correct.Auto-unlock error handling (
AdminWatchlistOperationsService.ts:215-227): TheunlockSignupUsermethod catches errors and logs them but does not throw. This means if unlock fails, the watchlist deletion still succeeds. Confirm this is the desired behavior (deletion should not be blocked by unlock failures).Non-atomic unlock (
UserRepository.ts:1440-1459):unlockByEmailusesfindFirst+update(two queries). There's a theoretical race condition if the user gets locked between find and update. Low risk but worth noting.findEntriesByIdsinterface expansion (WatchlistRepository.ts:237-244): Now returnssource,type,valuefields. Verify no other callers depend on the previous narrower return type.Link to Devin run: https://app.devin.ai/sessions/89436f0e54694e308731b95c32036f1d
Requested by: @alishaz-polymath