Added OTP Verification for Phone Number Updates#52
Conversation
Co-authored-by: Fortune Oluwasemilore Alebiosu <fortunealebiosu710@gmail.com>
Co-authored-by: Fortune Oluwasemilore Alebiosu <fortunealebiosu710@gmail.com>
Co-authored-by: Fortune Oluwasemilore Alebiosu <fortunealebiosu710@gmail.com>
Co-authored-by: Fortune Oluwasemilore Alebiosu <fortunealebiosu710@gmail.com>
Co-authored-by: Fortune Oluwasemilore Alebiosu <fortunealebiosu710@gmail.com>
Co-authored-by: Fortune Oluwasemilore Alebiosu <fortunealebiosu710@gmail.com>
…tom-sheet-eca6 Phone number bottom sheet
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughThis PR adds comprehensive React Native development guidelines for AI agents across 35+ documentation rules, implements end-to-end phone-based OTP verification with backend FastAPI endpoints and frontend UI components, introduces timezone-aware date handling utilities, creates supporting database schema with RLS policies, and updates configuration and type definitions. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Frontend Client
participant Backend as FastAPI Server
participant Twilio as Twilio SMS API
participant DB as Supabase Database
rect rgba(100, 150, 200, 0.5)
Note over Client,DB: Phase 1: Start OTP
Client->>Backend: POST /user/phone/otp/start<br/>(phone_number)
Backend->>DB: Upsert phone_number_updates<br/>(user_id, phone_number, otp_hash)
DB-->>Backend: Confirmation
Backend->>Twilio: Send SMS with OTP
Twilio-->>Backend: Success/Error
Backend-->>Client: Response
end
rect rgba(150, 100, 200, 0.5)
Note over Client,DB: Phase 2: Resend OTP
Client->>Backend: POST /user/phone/otp/resend<br/>(optional phone_number)
Backend->>DB: Fetch existing pending record
DB-->>Backend: phone_number_updates record
Backend->>DB: Update otp_hash & created_at
DB-->>Backend: Confirmation
Backend->>Twilio: Send SMS with new OTP
Twilio-->>Backend: Success/Error
Backend-->>Client: Response (with cooldown)
end
rect rgba(200, 150, 100, 0.5)
Note over Client,DB: Phase 3: Verify OTP
Client->>Backend: POST /user/phone/otp/verify<br/>(phone_number, otp)
Backend->>DB: Fetch phone_number_updates
DB-->>Backend: otp_hash, created_at
Backend->>Backend: Hash provided OTP<br/>Check expiration (10 min)<br/>Compare hashes
alt OTP Valid
Backend->>DB: RPC rpc_verify_and_update_phone<br/>(user_id, phone_number, otp)
DB->>DB: Update profiles.phone_number<br/>Delete phone_number_updates
DB-->>Backend: Success JSON
Backend-->>Client: Confirmation
Client->>Client: Refresh auth state<br/>Clear prompt
else OTP Invalid/Expired
Backend-->>Client: Error response
Client->>Client: Show error toast
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes The PR spans multiple distinct domains (frontend components, backend routing, database schema, cryptography, timezone utilities) with varying logic density. While the 35+ documentation rules are repetitive and homogeneous, the functional changes involve careful review of: OTP hashing/verification, Twilio integration error handling, RLS policy correctness, async synchronization locks, client-side phone validation, and timezone conversion logic across multiple files. The heterogeneous nature of changes across different subsystems and the need to verify security-sensitive operations (OTP, hashing, RLS) elevate the effort. Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| if not res.data: | ||
| raise HTTPException(status_code=404, detail="No pending phone verification record found") | ||
|
|
||
| phone_number = res.data[0].get("phone_number") |
There was a problem hiding this comment.
Missing phone number validation after database fetch
Medium Severity
In resend_phone_otp, after fetching the phone number from the database with res.data[0].get("phone_number"), there's no validation that the returned value is actually a valid phone number. If the database record exists but the phone_number column is null, the code proceeds to call _send_sms_otp with None, which will fail with a misleading "Failed to send OTP SMS" error from Twilio rather than a clear validation error.
| ) | ||
| except ValueError as e: | ||
| logger.exception("Failed to parse created_at timestamp") | ||
| raise HTTPException(status_code=500, detail="Invalid timestamp in verification record") from e |
There was a problem hiding this comment.
Unhandled AttributeError when created_at is null
Low Severity
In verify_phone_otp, created_at_str is retrieved via record.get("created_at") which returns None if the column is null. Line 232 then calls created_at_str.replace("Z", "+00:00"), which would raise an AttributeError on None. The try-except block only catches ValueError, so this AttributeError would propagate as an unhandled 500 error with no meaningful message.


Note
High Risk
Introduces new OTP/SMS verification endpoints and credentialed Twilio integration plus a client flow that updates user phone numbers via RPC; authentication, PII, and external API failure modes make this change security- and reliability-sensitive.
Overview
Adds a phone-number verification flow: backend exposes new
/user/phone/otp/startand/user/phone/otp/resendendpoints (Twilio SMS) and configures Twilio env vars; the legacy/user/phone/otp/verifyendpoint remains but is marked deprecated in favor of a Supabase RPC-based atomic verify+update.Updates the mobile app to prompt users to add/verify a phone number when entering
/capture, including a newPhoneNumberBottomSheet, local device-based prompt suppression (skip/don’t ask again), and a hook to read pendingphone_number_updatesrecords; OTP verification is performed viasupabase.rpc('rpc_verify_and_update_phone', ...).Improves date handling across calendar/vault views by routing date grouping/filtering through
useTimezone().getLocalDateStringand adjusting vault date parsing to avoid UTC drift. Also refactors backend ingestion to lazily initialize Pinecone (async, lock-protected) and tweaks a Supabase query in notification lookup to usesupabase.table(...)directly.Written by Cursor Bugbot for commit ab6fe2a. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
New Features
Documentation