Bug 965461 - ensure sync itself and sync prefs pane considers we are logged in after key fetch. r=ttaubert
authorMark Hammond <mhammond@skippinet.com.au>
Thu, 30 Jan 2014 14:50:31 -0800
changeset 182213 79d112ec7aa6b6e47f8630b965365298ae643463
parent 182212 96a80f54716ef5c26bfd6ac5a8ac21f77971ec17
child 182214 92ad158c1c79dd20eefa465a1285f86b6d3eeb32
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs965461
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 965461 - ensure sync itself and sync prefs pane considers we are logged in after key fetch. r=ttaubert
browser/components/preferences/sync.js
services/sync/modules/browserid_identity.js
--- a/browser/components/preferences/sync.js
+++ b/browser/components/preferences/sync.js
@@ -122,23 +122,33 @@ let gSyncPane = {
         // server rejected our credentials (eg, password changed on the server)
         let fxaLoginStatus = document.getElementById("fxaLoginStatus");
         let enginesListDisabled;
         // Not Verfied implies login error state, so check that first.
         if (!data.verified) {
           fxaLoginStatus.selectedIndex = FXA_LOGIN_UNVERIFIED;
           enginesListDisabled = true;
         // So we think we are logged in, so login problems are next.
-        } else if (Weave.Status.login != Weave.LOGIN_SUCCEEDED) {
-          fxaLoginStatus.selectedIndex = FXA_LOGIN_FAILED;
-          enginesListDisabled = true;
-        // Else we must be golden!
+        // (Although if the Sync identity manager is still initializing, we
+        // ignore login errors and assume all will eventually be good.)
         } else {
-          fxaLoginStatus.selectedIndex = FXA_LOGIN_VERIFIED;
-          enginesListDisabled = false;
+          // Weave might not have got around to re-checking if auth is OK,
+          // so tell it to do that now.
+          if (Weave.Status.login != Weave.LOGIN_SUCCEEDED) {
+            Weave.Service.verifyLogin();
+          }
+          if (Weave.Service.identity.readyToAuthenticate &&
+              Weave.Status.login != Weave.LOGIN_SUCCEEDED) {
+            fxaLoginStatus.selectedIndex = FXA_LOGIN_FAILED;
+            enginesListDisabled = true;
+          // Else we must be golden!
+          } else {
+            fxaLoginStatus.selectedIndex = FXA_LOGIN_VERIFIED;
+            enginesListDisabled = false;
+          }
         }
         document.getElementById("fxaEmailAddress1").textContent = data.email;
         document.getElementById("fxaEmailAddress2").textContent = data.email;
         document.getElementById("fxaEmailAddress3").textContent = data.email;
         document.getElementById("fxaSyncComputerName").value = Weave.Service.clientsEngine.localName;
         let enginesList = document.getElementById("fxaSyncEnginesList")
         enginesList.disabled = enginesListDisabled;
         // *sigh* - disabling the <richlistbox> draws each item as if it is disabled,
--- a/services/sync/modules/browserid_identity.js
+++ b/services/sync/modules/browserid_identity.js
@@ -90,17 +90,16 @@ this.BrowserIDManager.prototype = {
 
   initializeWithCurrentIdentity: function() {
     this._log.trace("initializeWithCurrentIdentity");
     Components.utils.import("resource://services-sync/main.js");
 
     // Reset the world before we do anything async.
     this.whenReadyToAuthenticate = Promise.defer();
     this._shouldHaveSyncKeyBundle = false;
-    this.username = ""; // this calls resetCredentials which drops the key bundle.
 
     return fxAccounts.getSignedInUser().then(accountData => {
       if (!accountData) {
         this._log.info("initializeWithCurrentIdentity has no user logged in");
         this._account = null;
         return;
       }