Bug 1277026 - Allow FxAccounts#getDeviceId callers to get only the cached deviceId. r?markh draft
authorEdouard Oger <eoger@fastmail.com>
Thu, 02 Jun 2016 16:06:50 -0700
changeset 375260 f7766dd28894ffb5c048b8641acadbffa79a5739
parent 375259 758725762a627f576de42da46dbe2ef7a77b3a0d
child 375261 304ccbfe8571197d08404735c2aff1b38bfda447
push id20199
push userbmo:edouard.oger@gmail.com
push dateFri, 03 Jun 2016 18:41:27 +0000
reviewersmarkh
bugs1277026
milestone49.0a1
Bug 1277026 - Allow FxAccounts#getDeviceId callers to get only the cached deviceId. r?markh MozReview-Commit-ID: H4LynNiYIg7
services/fxaccounts/FxAccounts.jsm
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -606,22 +606,22 @@ FxAccountsInternal.prototype = {
   /**
    * Invalidate the FxA certificate, so that it will be refreshed from the server
    * the next time it is needed.
    */
   invalidateCertificate() {
     return this.currentAccountState.updateUserAccountData({ cert: null });
   },
 
-  getDeviceId() {
+  getDeviceId(localOnly) {
     return this.currentAccountState.getUserAccountData()
       .then(data => {
         if (data) {
-          if (!data.deviceId || !data.deviceRegistrationVersion ||
-              data.deviceRegistrationVersion < this.DEVICE_REGISTRATION_VERSION) {
+          if (!localOnly && (!data.deviceId || !data.deviceRegistrationVersion ||
+              data.deviceRegistrationVersion < this.DEVICE_REGISTRATION_VERSION)) {
             // There is no device id or the device registration is outdated.
             // Either way, we should register the device with FxA
             // before returning the id to the caller.
             return this._registerOrUpdateDevice(data);
           }
 
           // Return the device id that we already registered with the server.
           return data.deviceId;