Bug 1296767 part 12 - Remove Weave.fxAccountsEnabled. r=markh

MozReview-Commit-ID: L4dM9xN2ELp
This commit is contained in:
Edouard Oger 2017-01-19 14:53:37 -05:00
parent ad36606986
commit ffa8a4f046
5 changed files with 16 additions and 156 deletions

View File

@ -161,11 +161,6 @@ var gFxAccounts = {
profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled"); profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled");
} catch (e) { } } catch (e) { }
// Bail out if FxA is disabled.
if (!this.weave.fxAccountsEnabled) {
return Promise.resolve();
}
this.panelUIFooter.hidden = false; this.panelUIFooter.hidden = false;
// Make sure the button is disabled in customization mode. // Make sure the button is disabled in customization mode.

View File

@ -97,41 +97,22 @@ var gSyncUI = {
// Returns a promise that resolves with true if Sync needs to be configured, // Returns a promise that resolves with true if Sync needs to be configured,
// false otherwise. // false otherwise.
_needsSetup() { _needsSetup() {
// If Sync is configured for FxAccounts then we do that promise-dance. return fxAccounts.getSignedInUser().then(user => {
if (this.weaveService.fxAccountsEnabled) { // We want to treat "account needs verification" as "needs setup".
return fxAccounts.getSignedInUser().then(user => { return !(user && user.verified);
// We want to treat "account needs verification" as "needs setup". });
return !(user && user.verified);
});
}
// We are using legacy sync - check that.
let firstSync = "";
try {
firstSync = Services.prefs.getCharPref("services.sync.firstSync");
} catch (e) { }
return Promise.resolve(Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
firstSync == "notReady");
}, },
// Returns a promise that resolves with true if the user currently signed in // Returns a promise that resolves with true if the user currently signed in
// to Sync needs to be verified, false otherwise. // to Sync needs to be verified, false otherwise.
_needsVerification() { _needsVerification() {
// For callers who care about the distinction between "needs setup" and return fxAccounts.getSignedInUser().then(user => {
// "needs verification" // If there is no user, they can't be in a "needs verification" state.
if (this.weaveService.fxAccountsEnabled) { if (!user) {
return fxAccounts.getSignedInUser().then(user => { return false;
// If there is no user, they can't be in a "needs verification" state. }
if (!user) { return !user.verified;
return false; });
}
return !user.verified;
});
}
// Otherwise we are configured for legacy Sync, which has no verification
// concept.
return Promise.resolve(false);
}, },
// Note that we don't show login errors in a notification bar here, but do // Note that we don't show login errors in a notification bar here, but do

View File

@ -92,17 +92,6 @@ WeaveService.prototype = {
return deferred.promise; return deferred.promise;
}, },
/**
* Whether Firefox Accounts is enabled.
*
* @return bool
*/
// TODO - Remove this getter and all accessors
get fxAccountsEnabled() {
// Always return true.
return true;
},
/** /**
* Whether Sync appears to be enabled. * Whether Sync appears to be enabled.
* *

View File

@ -1,88 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = [
"Authentication",
];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://services-sync/main.js");
Cu.import("resource://tps/logger.jsm");
/**
* Helper object for deprecated Firefox Sync authentication
*/
var Authentication = {
/**
* Check if an user has been logged in
*/
get isLoggedIn() {
return !!this.getSignedInUser();
},
/**
* Wrapper to retrieve the currently signed in user
*
* @returns Information about the currently signed in user
*/
getSignedInUser: function getSignedInUser() {
let user = null;
if (Weave.Service.isLoggedIn) {
user = {
email: Weave.Service.identity.account,
password: Weave.Service.identity.basicPassword,
passphrase: Weave.Service.identity.syncKey
};
}
return user;
},
/**
* Wrapper to synchronize the login of a user
*
* @param account
* Account information of the user to login
* @param account.username
* The username for the account (utf8)
* @param account.password
* The user's password
* @param account.passphrase
* The users's passphrase
*/
signIn: function signIn(account) {
Logger.AssertTrue(account["username"], "Username has been found");
Logger.AssertTrue(account["password"], "Password has been found");
Logger.AssertTrue(account["passphrase"], "Passphrase has been found");
Logger.logInfo("Logging in user: " + account["username"]);
Weave.Service.identity.account = account["username"];
Weave.Service.identity.basicPassword = account["password"];
Weave.Service.identity.syncKey = account["passphrase"];
if (Weave.Status.login !== Weave.LOGIN_SUCCEEDED) {
Logger.logInfo("Logging into Weave.");
Weave.Service.login();
Logger.AssertEqual(Weave.Status.login, Weave.LOGIN_SUCCEEDED,
"Weave logged in");
// Bug 997279: Temporary workaround until we can ensure that Sync itself
// sends this notification for the first login attempt by TPS
Weave.Svc.Obs.notify("weave:service:setup-complete");
}
return true;
},
signOut() {
Weave.Service.logout();
}
};

View File

@ -129,12 +129,6 @@ var TPS = {
shouldValidateForms: false, shouldValidateForms: false,
_init: function TPS__init() { _init: function TPS__init() {
// Check if Firefox Accounts is enabled
let service = Cc["@mozilla.org/weave/service;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
this.fxaccounts_enabled = service.fxAccountsEnabled;
this.delayAutoSync(); this.delayAutoSync();
OBSERVER_TOPICS.forEach(function(aTopic) { OBSERVER_TOPICS.forEach(function(aTopic) {
@ -143,12 +137,7 @@ var TPS = {
// Configure some logging prefs for Sync itself. // Configure some logging prefs for Sync itself.
Weave.Svc.Prefs.set("log.appender.dump", "Debug"); Weave.Svc.Prefs.set("log.appender.dump", "Debug");
// Import the appropriate authentication module Cu.import("resource://tps/auth/fxaccounts.jsm", module);
if (this.fxaccounts_enabled) {
Cu.import("resource://tps/auth/fxaccounts.jsm", module);
} else {
Cu.import("resource://tps/auth/sync.jsm", module);
}
}, },
DumpError(msg, exc = null) { DumpError(msg, exc = null) {
@ -860,7 +849,6 @@ var TPS = {
Logger.logInfo("Firefox version: " + Services.appinfo.version); Logger.logInfo("Firefox version: " + Services.appinfo.version);
Logger.logInfo("Firefox source revision: " + (AppConstants.SOURCE_REVISION_URL || "unknown")); Logger.logInfo("Firefox source revision: " + (AppConstants.SOURCE_REVISION_URL || "unknown"));
Logger.logInfo("Firefox platform: " + AppConstants.platform); Logger.logInfo("Firefox platform: " + AppConstants.platform);
Logger.logInfo("Firefox Accounts enabled: " + this.fxaccounts_enabled);
// do some sync housekeeping // do some sync housekeeping
if (Weave.Service.isLoggedIn) { if (Weave.Service.isLoggedIn) {
@ -1136,18 +1124,13 @@ var TPS = {
} }
Logger.logInfo("Setting client credentials and login."); Logger.logInfo("Setting client credentials and login.");
let account = this.fxaccounts_enabled ? this.config.fx_account Authentication.signIn(this.config.fx_account);
: this.config.sync_account;
Authentication.signIn(account);
this.waitForSetupComplete(); this.waitForSetupComplete();
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK"); Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK");
this.waitForTracking(); this.waitForTracking();
// If fxaccounts is enabled we get an initial sync at login time - let // We get an initial sync at login time - let that complete.
// that complete. this._triggeredSync = true;
if (this.fxaccounts_enabled) { this.waitForSyncFinished();
this._triggeredSync = true;
this.waitForSyncFinished();
}
}, },
/** /**