diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-05 00:24:31 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-05 00:24:31 +0000 |
commit | a19429c14b0c4e8f1bfa84baf2397c69aa964360 (patch) | |
tree | 083466a24d0c9536fdf9a19a7ded78a903ba94ce /remoting/webapp | |
parent | 749d59a04b22c1233af7e969bfd3b65ccb99fdab (diff) | |
download | chromium_src-a19429c14b0c4e8f1bfa84baf2397c69aa964360.zip chromium_src-a19429c14b0c4e8f1bfa84baf2397c69aa964360.tar.gz chromium_src-a19429c14b0c4e8f1bfa84baf2397c69aa964360.tar.bz2 |
[Chromoting] Require that the daemon PIN consists of 6 or more digits.
BUG=121516
Review URL: https://chromiumcodereview.appspot.com/9939013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130786 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r-- | remoting/webapp/_locales/en/messages.json | 4 | ||||
-rw-r--r-- | remoting/webapp/host_setup_dialog.js | 41 |
2 files changed, 40 insertions, 5 deletions
diff --git a/remoting/webapp/_locales/en/messages.json b/remoting/webapp/_locales/en/messages.json index 6fd5111..2c7458a 100644 --- a/remoting/webapp/_locales/en/messages.json +++ b/remoting/webapp/_locales/en/messages.json @@ -290,6 +290,10 @@ "message": "Once they enter the code your sharing session will begin.", "description": "Instructions shown below the access code when it is ready to be conveyed to the client." }, + "INVALID_PIN": { + "message": "Please enter a PIN consisting of 6 or more digits.", + "description": "An error message displayed if the user enters an invalid PIN while setting up a host." + }, "IT2ME_FIRST_RUN": { "message": "User-to-user screen sharing, perfect for remote technical support.", "description": "Description of the 'IT2Me' remote support functionality, displayed until the user clicks a 'get started' button, at which point it is replaced by the actual UI for that functionality." diff --git a/remoting/webapp/host_setup_dialog.js b/remoting/webapp/host_setup_dialog.js index fc9549c..0ba2cae 100644 --- a/remoting/webapp/host_setup_dialog.js +++ b/remoting/webapp/host_setup_dialog.js @@ -430,17 +430,48 @@ remoting.HostSetupDialog.prototype.onPinSubmit_ = function() { l10n.localizeElementFromTag( this.pinErrorMessage_, /*i18n-content*/'PINS_NOT_EQUAL'); this.pinErrorDiv_.hidden = false; - this.pinEntry_.value = ''; - this.pinConfirm_.value = ''; - this.pinEntry_.focus(); + this.prepareForPinEntry_(); + return; + } + if (!remoting.HostSetupDialog.validPin_(pin1)) { + l10n.localizeElementFromTag( + this.pinErrorMessage_, /*i18n-content*/'INVALID_PIN'); + this.pinErrorDiv_.hidden = false; + this.prepareForPinEntry_(); return; - } else { - this.pinErrorDiv_.hidden = true; } + this.pinErrorDiv_.hidden = true; this.flow_.pin = pin1; this.flow_.switchToNextStep(remoting.DaemonPlugin.AsyncResult.OK); this.updateState_(); }; +/** @private */ +remoting.HostSetupDialog.prototype.prepareForPinEntry_ = function() { + this.pinEntry_.value = ''; + this.pinConfirm_.value = ''; + this.pinEntry_.focus(); +}; + +/** + * Returns whether a PIN is valid. + * + * @private + * @param {string} pin A PIN. + * @return {boolean} Whether the PIN is valid. + */ +remoting.HostSetupDialog.validPin_ = function(pin) { + if (pin.length < 6) { + return false; + } + for (var i = 0; i < pin.length; i++) { + var c = pin.charAt(i); + if ((c < '0') || (c > '9')) { + return false; + } + } + return true; +} + /** @type {remoting.HostSetupDialog} */ remoting.hostSetupDialog = null; |