feat: Add phone number support to ClerkUser state#19
Conversation
There was a problem hiding this comment.
Pull request overview
Adds phone number support to the ClerkUser state so apps can read and update a user’s phone number via the Clerk backend API.
Changes:
- Adds
phone_numberandphone_number_idtoClerkUserand loads them inload_user. - Introduces
ClerkUser.update_phone_numberplus a standaloneupdate_user_phone_numberhelper. - Adds a GitHub Actions workflow intended to sync a fork with upstream.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| custom_components/reflex_clerk_api/clerk_provider.py | Adds phone number fields, loading, and update APIs for Clerk users. |
| .github/workflows/sync-upstream.yml | Adds an automated upstream sync workflow (not related to phone number support). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unrelated sync-upstream.yml workflow (should be in separate PR) - Fix primary phone number selection to use primary_phone_number_id - Refactor ClerkUser.update_phone_number to use helper (DRY principle) - Add verified parameter (default False) for security-conscious phone updates - Fix PII logging: use DEBUG level, redact sensitive identifiers - Fix docstring: remove incorrect 'unchanged' return case - Export update_user_phone_number in __init__.py Addresses Copilot code review comments on PR TimChild#19
- Add phone_number and phone_number_id properties to ClerkUser - Add update_phone_number method with verified parameter (default: False) - Add update_user_phone_number helper function for custom handlers - Load primary phone number in load_user event handler - Export update_user_phone_number in package __init__.py
|
Hey Tim! 👋 Thanks for maintaining this excellent library - we've been using it extensively in our Longevity Clinic project. I've reviewed the phone number support feature and here's a summary with suggestions: ✅ What's Good
📝 Suggestions Based on Copilot ReviewI agree with several of Copilot's points:
📚 Documentation NeedsThe - **ClerkUser**: Provides access to additional user information like `image_url`, `email_address`, `phone_number`, and `phone_number_id`.And perhaps a brief example: # Accessing phone number
clerk_user = await self.get_state(clerk.ClerkUser)
print(clerk_user.phone_number) # E.164 format: +12025551234
# Updating phone number (from any event handler)
await clerk.update_user_phone_number(self, '+12025551234')🚀 OverallThis is a solid addition that we're already using in production. Happy to help with any follow-up changes!
|
|
Thanks @supmo668! Glad it has been useful to you, and thanks a lot for the PR... Looks great! |
Summary
This PR adds phone number support to the
ClerkUserstate class, enabling applications to access and manage user phone numbers through the Clerk API.Changes
phone_numberandphone_number_idproperties toClerkUserstateupdate_phone_numbermethod toClerkUserfor updating user phone numbersupdate_user_phone_numberhelper function for use in custom event handlersload_userevent handlerUsage Example
Notes
phone_number_idis needed for updating/deleting phone numbers via Clerk API