Skip to content

LG-8976: Allow using Puerto Rico phone numbers for hybrid handoff#7874

Merged
matthinz merged 12 commits intomainfrom
matthinz/8976-pr-phone-hybrid
Feb 27, 2023
Merged

LG-8976: Allow using Puerto Rico phone numbers for hybrid handoff#7874
matthinz merged 12 commits intomainfrom
matthinz/8976-pr-phone-hybrid

Conversation

@matthinz
Copy link
Contributor

@matthinz matthinz commented Feb 22, 2023

🎫 Ticket

LG-8976

(Also a dash of LG-8839, since I was in there.)

🛠 Summary of changes

A user reported an issue using their Puerto Rican phone number for IdV's hybrid handoff screen. In this case, they had their phone number prefilled, since they were using it for SMS 2FA. It's likely this came in with #7762.

📜 Testing Plan

  • Sign up using a Puerto Rican phone number for SMS 2FA (area code 787 or 939)
  • Start IdV and select the "Use your phone to take photos" path
  • Leave your 2fa phone number pre-filled and click "Send Link"
  • Get a link!

@matthinz matthinz force-pushed the matthinz/8976-pr-phone-hybrid branch 2 times, most recently from 727f848 to 956ea79 Compare February 23, 2023 21:16
Comment on lines 168 to 172
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were updating the underlying country code <select> on change, but not on initialization.

@matthinz matthinz force-pushed the matthinz/8976-pr-phone-hybrid branch from 3b294ce to 747601c Compare February 24, 2023 20:15
Looks like we can have disagreement between what the backend thinks the country is and what the frontend does. Here we're letting the frontend win.
…e blocking some Puerto Rico users from using their phones to take pictures of their identity documents.
Was leading to input being initialized to "+1"
Use Phonelib to parse the country out of the user's phone number and intialize the `international_code` dropdown rendered by `PhoneInputComponent`

Update `PhoneFormatter` to use `national` format for the default country (US), `international` for others.
This change probably broke a bunch of tests anyway
Init from previous_params if there, otherwise infer from phone number.
(There are some cases where the international_code value is not submitted, e.g. fetch() calls)

Also took the opportunity to integrate new tests better with existing test infra
@matthinz matthinz force-pushed the matthinz/8976-pr-phone-hybrid branch from 747601c to 53c314e Compare February 24, 2023 20:35
We format PR numbers as just (XXX) XXX-XXXX on the front end
@matthinz matthinz marked this pull request as ready for review February 24, 2023 22:04
user_phone = MfaContext.new(user).phone_configurations.take&.phone
user_phone if valid_phone?(user_phone, phone_confirmed: true)
# @return [Array<string,string>] The international_code and phone values to use.
def determine_initial_values(international_code: nil, phone: nil, **_)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, we were initializing the phone field but not the international_code field. This could lead to cases where non-US phone numbers would end up not passing client-side validation, since the PhoneInputComponent would attempt to parse them as with a US country code.

Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +168 to +171
const country = iti.getSelectedCountryData();
if (country.iso2 && this.codeInput) {
this.codeInput.value = country.iso2.toUpperCase();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important that we avoid the change event that would be triggered by calling to syncCountryChangeToCodeInput instead?

Suggested change
const country = iti.getSelectedCountryData();
if (country.iso2 && this.codeInput) {
this.codeInput.value = country.iso2.toUpperCase();
}
this.syncCountryChangeToCodeInput();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we add some JavaScript test coverage for these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I originally tried just calling syncCountryChangeToCodeInput, but I believe it would replace a blank value with "+1" initially, which looked strange.

@matthinz matthinz merged commit d4fe232 into main Feb 27, 2023
@matthinz matthinz deleted the matthinz/8976-pr-phone-hybrid branch February 27, 2023 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants