Commit 4fefdfc1 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS Cellular] Select invalid PIN inputs.

A previous CL [1] ensured that valid but incorrect inputs were selected
after a failed attempt. However, this fix missed an edge case of inputs
which are invalid (e.g., PINs which contain letters instead of digits).

This CL causes these invalid values to be selected when they fail
validation.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1733421

Bug: 986793
Change-Id: Ib0d94219ebdd59af49f9b3cf35c3cbb92f27ada1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1790094
Auto-Submit: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694468}
parent bf552a54
...@@ -525,7 +525,8 @@ Polymer({ ...@@ -525,7 +525,8 @@ Polymer({
/** /**
* Checks whether |pin1| is of the proper length and contains only digits. * Checks whether |pin1| is of the proper length and contains only digits.
* If opt_pin2 is not undefined, then it also checks whether pin1 and * If opt_pin2 is not undefined, then it also checks whether pin1 and
* opt_pin2 match. On any failure, sets |this.error_| and returns false. * opt_pin2 match. On any failure, sets |this.error_|, focuses the invalid
* PIN, and returns false.
* @param {string} pin1 * @param {string} pin1
* @param {string=} opt_pin2 * @param {string=} opt_pin2
* @return {boolean} True if the pins match and are of minimum length. * @return {boolean} True if the pins match and are of minimum length.
...@@ -537,10 +538,12 @@ Polymer({ ...@@ -537,10 +538,12 @@ Polymer({
} }
if (pin1.length < PIN_MIN_LENGTH || !DIGITS_ONLY_REGEX.test(pin1)) { if (pin1.length < PIN_MIN_LENGTH || !DIGITS_ONLY_REGEX.test(pin1)) {
this.error_ = ErrorType.INVALID_PIN; this.error_ = ErrorType.INVALID_PIN;
this.focusDialogInput_();
return false; return false;
} }
if (opt_pin2 != undefined && pin1 != opt_pin2) { if (opt_pin2 != undefined && pin1 != opt_pin2) {
this.error_ = ErrorType.MISMATCHED_PIN; this.error_ = ErrorType.MISMATCHED_PIN;
this.focusDialogInput_();
return false; return false;
} }
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment