robinhood / deux

Multifactor Authentication for Django Rest Framework
Other
156 stars 56 forks source link

Phone validator does not allow a "+" prefix #16

Open willjleongdv opened 6 years ago

willjleongdv commented 6 years ago

With the Twillio SMS challenge, foreign numbers (only non-US numbers with the + prefix) do not work with twillio without a "+" prefix. The duex validator throws an validation error if the "+" is in the phone number string. Specifically, I was unable to enable mfa for a uk/french number what twillio required +44 or +33 for the sms/request register endpoint.

Consider changing phone_number_validator to support international numbers. Using a library like https://github.com/daviddrysdale/python-phonenumbers my be a more holistic approach.

validators.py Regex can look like this phone_number_validator = RegexValidator( regex=r"^(\+?\d{7,15})$", message=strings.INVALID_PHONE_NUMBER_ERROR )

jonstep commented 6 years ago

Hi @willjleongdv!

Funnily enough I had the same issue today and came up with same solution. I have created a PR with the fix, in the meantime feel free to use my forked version (https://github.com/jonstep/deux)