-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] Different types of phone numbers are allowed, but only mobile types should #487
Conversation
@nemesifier can you please review this PR for the issue #484 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ujjwalkirti thanks for contributing! We need a failing unit test which replicates the bug before we can merge a fix. Do you know how to write tests? If you look at https://github.com/openwisp/openwisp-radius/blob/master/openwisp_radius/tests/test_api/test_phone_verification.py you can find plenty of examples.
openwisp_radius/api/serializers.py
Outdated
@@ -430,6 +430,8 @@ class RegisterSerializer( | |||
def validate_phone_number(self, phone_number): | |||
org = self.context['view'].organization | |||
if get_organization_radius_settings(org, 'sms_verification'): | |||
if phonenumbers.phonenumberutil.number_type(phone_number) != 1: | |||
raise serializers.ValidationError(_('Landline numbers can\'t be used to send SMS.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd write that only mobile phone numbers are allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will make the required changes.
Hey @ujjwalkirti!! Thank for contributing. I will be taking over this PR to complete it. |
Closes #484 Co-authored-by: Gagan Deep <[email protected]>
[skip ci]
I changed the code to check whether phone_number provided is a Mobile number and raise expception if not. (#484 )
Below is the function code that I have altered.
Closes #484
Edited by @pandafy