Closed Bug 562183 Opened 14 years ago Closed 14 years ago

unify passphrase matching/validation code

Categories

(Firefox :: Sync, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mconnor, Assigned: mconnor)

References

Details

Attachments

(1 file, 1 obsolete file)

Attached patch v1 (obsolete) — Splinter Review
This is inconsistent, and duplicates code, and also led to duplicates for a number of strings.
Flags: blocking-weave1.3+
Attachment #441946 - Flags: review?(edilee)
Missing fx-prefs-common.js ?
Attached patch v1Splinter Review
oops
Attachment #441946 - Attachment is obsolete: true
Attachment #441972 - Flags: review?(edilee)
Attachment #441946 - Flags: review?(edilee)
Comment on attachment 441972 [details] [diff] [review]
v1

>+++ b/source/chrome/content/generic-change.js
>   validate: function (event) {
>     if (this._dialogType == "ChangePassword") {
>       if (this._currentPasswordInvalid)
>+        [valid, errorString] = gWeaveCommon.validatePassword(this._firstBox);
>+      else
>+        [valid, errorString] = gWeaveCommon.validatePassword(this._firstBox, this._secondBox);
>     }
>     else {
>       if (this._updatingPassphrase)
>+        [valid, errorString] = gWeaveCommon.validatePassphrase(this._firstBox);
>+      else
>+        [valid, errorString] = gWeaveCommon.validatePassphrase(this._firstBox, this._secondBox);
You could make the interface do..

let {valid, errorString} = gWeaveCommon.validatePassword(..)

Unrelated, not sure if it would be any better to do
.. = gWeaveCommon[validate].apply(gWeaveCommon, boxes)
where validate = dialogType == "Change" ? .. : .. and boxes = [first]; if (!invalid && !updating) boxes.push(second)

Mm.. maybe not :p

>+++ b/source/chrome/content/preferences/fx-prefs-common.js
>+var gWeaveCommon = {
var let?

>+  _validate: function (el1, el2, isPassword) {
>+    let errorString = error ? Weave.Utils.getErrorString(error) : "";
>+    dump("valid: " + valid + " error: " + errorString + "\n");
>+    return [valid, errorString];
And this would be:
return {
  errorString: errorString,
  valid: valid
};

>+++ b/source/chrome/content/preferences/fx-setup.js
>   onPasswordChange: function () {
>     let valid = false;
>+    let errorString = "";
>+    [valid, errorString] = gWeaveCommon.validatePassword(password, pwconfirm);
No need to separately declare/initialize and assign.

>+  _setFeedbackMessage: function (element, success, string) {
>-    label.className = classname;
No more error/success classes?
Attachment #441972 - Flags: review?(edilee) → review+
Blocks: 551612
http://hg.mozilla.org/labs/weave/rev/6e4b48a00d01
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.3b3
Depends on: 564523
Component: Firefox Sync: UI → Sync
Product: Cloud Services → Firefox
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: