openwisp / openwisp-radius

Administration web interface and REST API for freeradius 3 build in django & python. Supports captive portal authentication, WPA Enerprise (802.1x), freeradius rlm_rest, social login, Hotspot 2.0 / 802.11u, importing users from CSV, registration of new users and more.
https://openwisp.io/docs/dev/radius/
GNU General Public License v3.0
366 stars 183 forks source link

[bug] Different types of phone numbers are allowed, but only mobile types should #484

Closed nemesifier closed 1 year ago

nemesifier commented 1 year ago

Landline numbers seem to be currently accepted, which will not work for sending SMS.

I think we have to edit this part of the code:

https://github.com/openwisp/openwisp-radius/blob/0cfe07133551d60479f85a8c4f619a39aa09495b/openwisp_radius/api/serializers.py#L430-L443

# assuming phone_number is a phonenumbers instance
phonenumbers.phonenumberutil.number_type(phone_number)

Possible return values according to the library's code:

FIXED_LINE = 0 MOBILE = 1 FIXED_LINE_OR_MOBILE = 2 TOLL_FREE = 3 PREMIUM_RATE = 4 SHARED_COST = 5 VOIP = 6 PERSONAL_NUMBER = 7 PAGER = 8 UAN = 9 VOICEMAIL = 10 UNKNOWN = 99

We shall accept only 1 (MOBILE).

ujjwalkirti commented 1 year ago

@nemesifier I have generated a pull request (#487 ) which contains the fix for this issue. Could you please have a look at it?