fix: Auto-filled phone numbers contain characters rejected by Cognito #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
Cognito's expectations for a phone number is to be fully numerical except for the initial
+
sign.Although the Authenticator's Phone Number Field only shows the numeric keyboard for manual input, it's still possible to end up with non-numeric characters by using the Auto-Fill option, or simply by pasting a phone number from the clipboard.
The problem is that phone numbers are typically formatted in a way that include hyphens, spaces and parentheses (e.g.
+1 (123) 456-7890
instead of just+11234567890
). So attempting to submit a phone number using any of these characters results in an error, as Cognito rejects the request.While the easiest fix would be to remove any non-numeric character from being displayed in the Phone Number Field, I've decided to allow them on the customer facing field, but remove them from the internal field that is used when submitting to Cognito. The reasoning for this is that striping formatting would create a subpar experience for customers using Auto-Fill or pasting phone numbers.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.