forked from mirrors/gecko-dev
Bug 1882339: Delay sync initialization until oauth message. r=skhamis,markh
Differential Revision: https://phabricator.services.mozilla.com/D202849
This commit is contained in:
parent
31f42f9bc3
commit
f80f8a5040
2 changed files with 38 additions and 21 deletions
|
|
@ -65,6 +65,13 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
true
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"oauthEnabled",
|
||||
"identity.fxaccounts.oauth.enabled",
|
||||
true
|
||||
);
|
||||
|
||||
export const ERROR_INVALID_ACCOUNT_STATE = "ERROR_INVALID_ACCOUNT_STATE";
|
||||
|
||||
// An AccountState object holds all state related to one specific account.
|
||||
|
|
@ -550,7 +557,7 @@ export class FxAccounts {
|
|||
await this.signOut();
|
||||
return null;
|
||||
}
|
||||
if (!this._internal.isUserEmailVerified(data)) {
|
||||
if (!this._internal.isUserEmailVerified(data) && !lazy.oauthEnabled) {
|
||||
// If the email is not verified, start polling for verification,
|
||||
// but return null right away. We don't want to return a promise
|
||||
// that might not be fulfilled for a long time.
|
||||
|
|
@ -995,7 +1002,8 @@ FxAccountsInternal.prototype = {
|
|||
);
|
||||
}
|
||||
await this.abortExistingFlow();
|
||||
let currentAccountState = (this.currentAccountState = this.newAccountState(
|
||||
const currentAccountState = (this.currentAccountState =
|
||||
this.newAccountState(
|
||||
Cu.cloneInto(credentials, {}) // Pass a clone of the credentials object.
|
||||
));
|
||||
// This promise waits for storage, but not for verification.
|
||||
|
|
@ -1004,7 +1012,7 @@ FxAccountsInternal.prototype = {
|
|||
// the background? Already does for updateAccountData ;)
|
||||
await currentAccountState.promiseInitialized;
|
||||
// Starting point for polling if new user
|
||||
if (!this.isUserEmailVerified(credentials)) {
|
||||
if (!this.isUserEmailVerified(credentials) && !lazy.oauthEnabled) {
|
||||
this.startVerifiedCheck(credentials);
|
||||
}
|
||||
await this.notifyObservers(ONLOGIN_NOTIFICATION);
|
||||
|
|
@ -1478,13 +1486,14 @@ FxAccountsInternal.prototype = {
|
|||
/** Sets the user to be verified in the account state,
|
||||
* This prevents any polling for the user's verification state from the FxA server
|
||||
**/
|
||||
setUserVerified() {
|
||||
return this.withCurrentAccountState(async currentState => {
|
||||
async setUserVerified() {
|
||||
await this.withCurrentAccountState(async currentState => {
|
||||
const userData = await currentState.getUserAccountData();
|
||||
if (!userData.verified) {
|
||||
await currentState.updateAccountData({ verified: true });
|
||||
await currentState.updateUserAccountData({ verified: true });
|
||||
}
|
||||
});
|
||||
await this.notifyObservers(ONVERIFIED_NOTIFICATION);
|
||||
},
|
||||
|
||||
async _getVerifiedAccountOrReject() {
|
||||
|
|
|
|||
|
|
@ -80,6 +80,13 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
val => Services.io.newURI(val)
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
lazy,
|
||||
"oauthEnabled",
|
||||
"identity.fxaccounts.oauth.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
// These engines were added years after Sync had been introduced, they need
|
||||
// special handling since they are system add-ons and are un-available on
|
||||
// older versions of Firefox.
|
||||
|
|
@ -487,9 +494,11 @@ FxAccountsWebChannelHelpers.prototype = {
|
|||
"webchannel"
|
||||
);
|
||||
|
||||
if (lazy.oauthEnabled) {
|
||||
await this._fxAccounts._internal.setSignedInUser(accountData);
|
||||
} else {
|
||||
const xps = await this._initializeSync();
|
||||
await this._fxAccounts._internal.setSignedInUser(accountData);
|
||||
|
||||
if (requestedServices) {
|
||||
// User has enabled Sync.
|
||||
if (requestedServices.sync) {
|
||||
|
|
@ -499,6 +508,7 @@ FxAccountsWebChannelHelpers.prototype = {
|
|||
await xps.Weave.Service.configure();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -628,9 +638,7 @@ FxAccountsWebChannelHelpers.prototype = {
|
|||
};
|
||||
},
|
||||
_getCapabilities() {
|
||||
if (
|
||||
Services.prefs.getBoolPref("identity.fxaccounts.oauth.enabled", false)
|
||||
) {
|
||||
if (lazy.oauthEnabled) {
|
||||
return {
|
||||
multiService: true,
|
||||
pairing: lazy.pairingEnabled,
|
||||
|
|
|
|||
Loading…
Reference in a new issue