author | Sam Penrose <spenrose@mozilla.com> |
Tue, 22 Apr 2014 15:28:18 -0700 | |
changeset 179731 | c6e856383007bce5825e7509873631dd7237f830 |
parent 179730 | 6fa987a53e37fcbb627c67149b416f1449a0042e |
child 179732 | 8685f4d027ea19acb48f46b2cc738124c1a358c3 |
push id | 26638 |
push user | ryanvm@gmail.com |
push date | Wed, 23 Apr 2014 20:03:20 +0000 |
treeherder | mozilla-central@3cd4615c60ba [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jedp |
bugs | 994934 |
milestone | 31.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
services/fxaccounts/FxAccounts.jsm | file | annotate | diff | comparison | revisions | |
services/fxaccounts/FxAccountsManager.jsm | file | annotate | diff | comparison | revisions |
--- a/services/fxaccounts/FxAccounts.jsm +++ b/services/fxaccounts/FxAccounts.jsm @@ -494,42 +494,58 @@ FxAccountsInternal.prototype = { log.debug("Polling aborted; Another user signing in"); clearTimeout(this.currentTimer); this.currentTimer = 0; } this.currentAccountState.abort(); this.currentAccountState = new AccountState(this); }, - signOut: function signOut() { + signOut: function signOut(localOnly) { let currentState = this.currentAccountState; - let fxAccountsClient = this.fxAccountsClient; let sessionToken; return currentState.getUserAccountData().then(data => { // Save the session token for use in the call to signOut below. sessionToken = data && data.sessionToken; - this.abortExistingFlow(); - this.currentAccountState.signedInUser = null; // clear in-memory cache - return this.signedInUserStorage.set(null); + return this._signOutLocal(); }).then(() => { - // Wrap this in a promise so *any* errors in signOut won't - // block the local sign out. This is *not* returned. - Promise.resolve().then(() => { - // This can happen in the background and shouldn't block - // the user from signing out. The server must tolerate - // clients just disappearing, so this call should be best effort. - return fxAccountsClient.signOut(sessionToken); - }).then(null, err => { - log.error("Error during remote sign out of Firefox Accounts: " + err); - }); + // FxAccountsManager calls here, then does its own call + // to FxAccountsClient.signOut(). + if (!localOnly) { + // Wrap this in a promise so *any* errors in signOut won't + // block the local sign out. This is *not* returned. + Promise.resolve().then(() => { + // This can happen in the background and shouldn't block + // the user from signing out. The server must tolerate + // clients just disappearing, so this call should be best effort. + return this._signOutServer(sessionToken); + }).then(null, err => { + log.error("Error during remote sign out of Firefox Accounts: " + err); + }); + } + }).then(() => { this.notifyObservers(ONLOGOUT_NOTIFICATION); }); }, /** + * This function should be called in conjunction with a server-side + * signOut via FxAccountsClient. + */ + _signOutLocal: function signOutLocal() { + this.abortExistingFlow(); + this.currentAccountState.signedInUser = null; // clear in-memory cache + return this.signedInUserStorage.set(null); + }, + + _signOutServer: function signOutServer(sessionToken) { + return this.fxAccountsClient.signOut(sessionToken); + }, + + /** * Fetch encryption keys for the signed-in-user from the FxA API server. * * Not for user consumption. Exists to cause the keys to be fetch. * * Returns user data so that it can be chained with other methods. * * @return Promise * The promise resolves to the credentials object of the signed-in user:
--- a/services/fxaccounts/FxAccountsManager.jsm +++ b/services/fxaccounts/FxAccountsManager.jsm @@ -158,17 +158,17 @@ this.FxAccountsManager = { } // We clear the local session cache as soon as we get the onlogout // notification triggered within FxAccounts.signOut, so we save the // session token value to be able to remove the remote server session // in case that we have network connection. let sessionToken = this._activeSession.sessionToken; - return this._fxAccounts.signOut(sessionToken).then( + return this._fxAccounts.signOut(true).then( () => { // At this point the local session should already be removed. // The client can create new sessions up to the limit (100?). // Orphaned tokens on the server will eventually be garbage collected. if (Services.io.offline) { return Promise.resolve(); }