12
113
Fork
You've already forked django-allauth
149

Add phone parameter to generate_phone_verification_code method #4579

Closed
omargawdat wants to merge 4 commits from omargawdat/django-allauth:feature/add-phone-parameter-to-verification-code into main
pull from: omargawdat/django-allauth:feature/add-phone-parameter-to-verification-code
merge into: allauth:main
allauth:main
allauth:fix/account-middleware-reauth-exc-vs-api
allauth:65.12.x
allauth:65.11.x
allauth:feat/openid-connect-id-token
allauth:fix/phone-vs-social-signup
allauth:65.8.x
allauth:feat/idp
allauth:feat/resend-code-or-change
allauth:fix/phone-signup-conflict
allauth:feat/phone
allauth:fix/headless-email-verification-by-code
allauth:fix/a11y
allauth:feat/facebook-limited-login
allauth:fix/headless-only-connect-reauth
allauth:fix/email-added-vs-code-verification
allauth:feat/login-required-middleware
allauth:0.63.x
allauth:refactor-unique-true-field
allauth:0.62.x
allauth:0.57.x
allauth:0.60.x
allauth:0.55.x
allauth:feat-metamask
First-time contributor
Copy link

[this issue is critical because in the current implementation we can't deploy an app for apple if the only authentication is phone number and OTP because they will require testing number and testing OTP]

we need to send the phone number into generate_phone_verification_code to being able to generate a specific code for testing numbers in different environments because we must have it if the only authentication is phone number

[this issue is critical because in the current implementation we can't deploy an app for apple if the only authentication is phone number and OTP because they will require testing number and testing OTP] we need to send the phone number into generate_phone_verification_code to being able to generate a specific code for testing numbers in different environments because we must have it if the only authentication is phone number
Add phone parameter to generate_phone_verification_code method
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
1aee9a38de
Pass phone number to generate_phone_verification_code() to enable
custom OTP generation based on phone number. This allows developers
to implement test phone numbers with predictable OTP codes for
testing and Apple App Store requirements.
Changes:
- Add optional phone parameter to generate_phone_verification_code()
- Pass phone number from PhoneVerificationProcess.send()
- Maintain backward compatibility with default None value
Fixes ability to customize OTP codes for specific phone numbers
during development and testing workflows.
Merge branch 'main' into feature/add-phone-parameter-to-verification-code
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
29cccc4f3e
Owner
Copy link

This is a backwards incompatible change. Other projects that did override this method are not prepared to receive these additional parameters.

So, it would be good if we could keep backwards compatibility, e.g. by adding a _generate_phone_verirification_code_compat() method that checks the signature (inspect.signature() of the method, and calls it accordingly).

Also, wouldn't it make be more generally useful to take both user and phone as inputs?

This is a backwards incompatible change. Other projects that did override this method are not prepared to receive these additional parameters. So, it would be good if we could keep backwards compatibility, e.g. by adding a `_generate_phone_verirification_code_compat()` method that checks the signature (`inspect.signature()` of the method, and calls it accordingly). Also, wouldn't it make be more generally useful to take both `user` and `phone` as inputs?
Add backwards compatibility for phone and user parameters
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
5fb820e1f2
Merge branch 'main' into feature/add-phone-parameter-to-verification-code
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
674721cc6a
Author
First-time contributor
Copy link

I made the requested improvement please let me know if there any other suggestions

just btw I thought about a simpler approach that will avoid using _generate_phone_verirification_code_compat and will still works for other versions

try:
 code = adapter.generate_phone_verification_code(phone=phone, user=user)
except TypeError:
 code = adapter.generate_phone_verification_code()
I made the requested improvement please let me know if there any other suggestions just btw I thought about a simpler approach that will avoid using _generate_phone_verirification_code_compat and will still works for other versions ``` try: code = adapter.generate_phone_verification_code(phone=phone, user=user) except TypeError: code = adapter.generate_phone_verification_code() ```

It's not really guaranteed that the TypeError is due to calling the method with the wrong number of arguments, or, whether the implementation of the method does something wrong and raises a TypeError by itself. So the signature inspection is more explicit. I have tweaked it a little bit to add a deprecation warning, and also to ensure the new signature is fixed to always have user and phone.

Closed via: bc98e9734

It's not really guaranteed that the `TypeError` is due to calling the method with the wrong number of arguments, or, whether the implementation of the method does something wrong and raises a `TypeError` by itself. So the signature inspection is more explicit. I have tweaked it a little bit to add a deprecation warning, and also to ensure the new signature is fixed to always have user and phone. Closed via: bc98e9734
pennersr closed this pull request 2025年10月26日 19:59:57 +01:00
Author
First-time contributor
Copy link

yeah sure thanks for letting me know

yeah sure thanks for letting me know
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
allauth/django-allauth!4579
Reference in a new issue
allauth/django-allauth
No description provided.
Delete branch "omargawdat/django-allauth:feature/add-phone-parameter-to-verification-code"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?