diff options
Diffstat (limited to 'services/fxaccounts/FxAccounts.sys.mjs')
-rw-r--r-- | services/fxaccounts/FxAccounts.sys.mjs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/services/fxaccounts/FxAccounts.sys.mjs b/services/fxaccounts/FxAccounts.sys.mjs index 790a6195f8..e258c99c2d 100644 --- a/services/fxaccounts/FxAccounts.sys.mjs +++ b/services/fxaccounts/FxAccounts.sys.mjs @@ -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. @@ -865,7 +872,7 @@ FxAccountsInternal.prototype = { _oauth: null, get oauth() { if (!this._oauth) { - this._oauth = new lazy.FxAccountsOAuth(this.fxAccountsClient); + this._oauth = new lazy.FxAccountsOAuth(this.fxAccountsClient, this.keys); } return this._oauth; }, @@ -995,16 +1002,17 @@ FxAccountsInternal.prototype = { ); } await this.abortExistingFlow(); - let currentAccountState = (this.currentAccountState = this.newAccountState( - Cu.cloneInto(credentials, {}) // Pass a clone of the credentials object. - )); + 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. // We're telling the caller that this is durable now (although is that // really something we should commit to? Why not let the write happen in // 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() { |