Bug 1277026 - Allow FxAccounts#getDeviceId callers to get only the cached deviceId. r?markh
MozReview-Commit-ID: H4LynNiYIg7
--- 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;