Fix unknown user auto-creation in messaging webhooks#82
Conversation
- Modify `AuthService.get_or_create_user` and `get_or_create_user_by_identity` to accept `create` flag. - Update `src/api/routes.py` (WhatsApp, Twilio, Generic, TextGrid webhooks) to invoke `get_or_create_user(..., create=False)`. - Implement registration prompt flow: if user is unknown, send a reply with `clerk_sign_up_url` instead of creating an account. - Add `clerk_sign_up_url` to `Settings`. - Update tests to reflect new behavior. Co-authored-by: MRiabov <108194191+MRiabov@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR implements the requirement from Spec 025 (Clerk Authentication) to prevent automatic user creation for unknown numbers messaging the CRM. Instead of creating a new business and user immediately, the system now replies with a registration link.
Changes:
src/services/auth_service.py: Addedcreateargument (defaultTrue) toget_or_create_userandget_or_create_user_by_identity.src/config/__init__.py: Addedclerk_sign_up_urlsetting.src/api/routes.py: Updated messaging webhooks to check for user existence without creation. If the user does not exist, a registration prompt is sent viaMessagingService.tests/test_twilio_webhook.py: Updated mock expectations.Verified with reproduction test (deleted) and existing tests.
PR created automatically by Jules for task 15567271081987070927 started by @MRiabov