-
-
Notifications
You must be signed in to change notification settings - Fork 544
bug: Phone number sanitisation #7371
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
Comments
Hi @mrfrase3, thanks for your report. Working on the fix . |
For existing users: #7382 #7385 For future registered phone number: @mrfrase3 Thanks again for bringing this up. Please take a look at the fixes above — we’ll include them in the next release. |
Thanks @simeng-li and the rest of the team getting on this, hopefully I haven't ruined the sprint velocity for you guys 😅 I've taken a look and it all looks good. Also worth noting that libphonenumber-js needs to be kept up-to-date somewhat frequently, as new number ranges are brought online all the time around the world, and if the lib isn't updated, you can start to get peoples new numbers rejecting. |
Describe the bug
It's common to represent a mobile number in two ways:
A non-discerning user (95% of users) is likely to input both, i.e. 61 0412 345 678, whilst technically incorrect, most phone validation libraries will chop off the 0 when parsing.
If you save the incorrect format via the admin console, the form does pass the value through the parsePhoneNumber util which strips the 0 and other formatting:
https://github.com/logto-io/logto/blob/master/packages/console/src/pages/Users/components/CreateForm/index.tsx#L87C56-L87C72
https://github.com/logto-io/logto/blob/master/packages/console/src/pages/UserDetails/UserSettings/index.tsx#L90
However, both the sign in and sign up experience flows do not, in fact they save/match purely on what the user types in.
So if there is a user with
primaryPhone
set to 61412345678 (from the console or signup) and they then enter 61 0412345678 during sign in, or vise versa, it will reject the users login attempt saying their account doesn't existThe main culprit is here in the SmartInput component:
It should be doing something like:
But also this is a deeper issue, where this sanitisation is currently only occurring on the frontend. It should also be occurring in:
findUserByPhone
hasUserWithPhone
insetUser
This has likely caused a larger issue as this has been in production for a long time, so there are now unsanitised phone numbers in all tennant databases that had the feature enabled. :S
Expected behavior
When signing in, either format, invalid or not, should work and sign me in:
What's saved in the database should be sanitised with parsePhoneNumber. i.e 61412345678
How to reproduce?
or
Environment
Logto Cloud
Screenshots
No response
The text was updated successfully, but these errors were encountered: