Bug 1532098 - Update login instead delete then add. r=nalexander a=lizzard
☠☠ backed out by d5a11a79f7bd ☠ ☠
authorEdouard Oger <eoger@fastmail.com>
Wed, 06 Mar 2019 17:52:30 +0000
changeset 516321 408920c5296e7f8e39ff3507d7fd903a5c0fade0
parent 516320 8ec48086dfd3329592d38492ee6c8f76e090922b
child 516322 d5a11a79f7bdfa73a6033e5198ae48c07791a4f7
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, lizzard
bugs1532098
milestone66.0
Bug 1532098 - Update login instead delete then add. r=nalexander a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D22346
mobile/android/chrome/content/aboutLogins.js
--- a/mobile/android/chrome/content/aboutLogins.js
+++ b/mobile/android/chrome/content/aboutLogins.js
@@ -288,22 +288,28 @@ var Logins = {
         this._showList();
         return;
       }
 
       let logins = Services.logins.findLogins({}, origDomain, origDomain, null);
 
       for (let i = 0; i < logins.length; i++) {
         if (logins[i].username == origUsername) {
-          let clone = logins[i].clone();
-          clone.username = newUsername;
-          clone.password = newPassword;
-          clone.hostname = newDomain;
-          Services.logins.removeLogin(logins[i]);
-          Services.logins.addLogin(clone);
+          let propBag = Cc["@mozilla.org/hash-property-bag;1"].
+            createInstance(Ci.nsIWritablePropertyBag);
+          if (newUsername !== origUsername) {
+            propBag.setProperty("username", newUsername);
+          }
+          if (newPassword !== origPassword) {
+            propBag.setProperty("password", newPassword);
+          }
+          if (newDomain !== origDomain) {
+            propBag.setProperty("hostname", newDomain);
+          }
+          Services.logins.modifyLogin(logins[i], propBag);
           break;
         }
       }
     } catch (e) {
       Snackbars.show(gStringBundle.GetStringFromName("editLogin.couldNotSave"), Snackbars.LENGTH_LONG);
       return;
     }
     Snackbars.show(gStringBundle.GetStringFromName("editLogin.saved1"), Snackbars.LENGTH_LONG);