Bug 1262272 - Unconditionally poll the verification status for FxA push messages. r?markh draft
authorKit Cambridge <kcambridge@mozilla.com>
Mon, 11 Apr 2016 11:08:58 -0700
changeset 350233 072310e59f20f59bfcdc8edf899e8c7446dd42ef
parent 350156 fb921246e2d60f521f83defed54e30a38df1be3e
child 518274 97e4758c7af032d8c92717b2f2ccb5a164a63008
push id15275
push userkcambridge@mozilla.com
push dateWed, 13 Apr 2016 01:14:20 +0000
reviewersmarkh
bugs1262272
milestone48.0a1
Bug 1262272 - Unconditionally poll the verification status for FxA push messages. r?markh MozReview-Commit-ID: Fb7F1bxHO8V
services/fxaccounts/FxAccounts.jsm
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -416,17 +416,18 @@ FxAccountsInternal.prototype = {
   /**
    * Ask the server whether the user's email has been verified
    */
   checkEmailStatus: function checkEmailStatus(sessionToken, options = {}) {
     if (!sessionToken) {
       return Promise.reject(new Error(
         "checkEmailStatus called without a session token"));
     }
-    return this.fxAccountsClient.recoveryEmailStatus(sessionToken, options);
+    return this.fxAccountsClient.recoveryEmailStatus(sessionToken,
+      options).catch(error => this._handleTokenError(error));
   },
 
   /**
    * Once the user's email is verified, we can request the keys
    */
   fetchKeys: function fetchKeys(keyFetchToken) {
     log.debug("fetchKeys: " + !!keyFetchToken);
     if (logPII) {
@@ -668,20 +669,25 @@ FxAccountsInternal.prototype = {
     log.trace('checkVerificationStatus');
     let currentState = this.currentAccountState;
     return currentState.getUserAccountData().then(data => {
       if (!data) {
         log.trace("checkVerificationStatus - no user data");
         return null;
       }
 
-      if (!this.isUserEmailVerified(data)) {
+      // Always check the verification status, even if the local state indicates
+      // we're already verified. If the user changed their password, the check
+      // will fail, and we'll enter the reauth state.
+      if (this.isUserEmailVerified(data)) {
+        log.trace("checkVerificationStatus - checking status for verified account");
+      } else {
         log.trace("checkVerificationStatus - forcing verification status check");
-        this.pollEmailStatus(currentState, data.sessionToken, "push");
       }
+      this.pollEmailStatus(currentState, data.sessionToken, "push");
     });
   },
 
   _destroyOAuthToken: function(tokenData) {
     let client = new FxAccountsOAuthGrantClient({
       serverURL: tokenData.server,
       client_id: FX_OAUTH_CLIENT_ID
     });