mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 13:21:28 +00:00
Bug 1296767 part 12 - Remove Weave.fxAccountsEnabled. r=markh
MozReview-Commit-ID: L4dM9xN2ELp
This commit is contained in:
parent
ad36606986
commit
ffa8a4f046
@ -161,11 +161,6 @@ var gFxAccounts = {
|
||||
profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled");
|
||||
} catch (e) { }
|
||||
|
||||
// Bail out if FxA is disabled.
|
||||
if (!this.weave.fxAccountsEnabled) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this.panelUIFooter.hidden = false;
|
||||
|
||||
// Make sure the button is disabled in customization mode.
|
||||
|
@ -97,41 +97,22 @@ var gSyncUI = {
|
||||
// Returns a promise that resolves with true if Sync needs to be configured,
|
||||
// false otherwise.
|
||||
_needsSetup() {
|
||||
// If Sync is configured for FxAccounts then we do that promise-dance.
|
||||
if (this.weaveService.fxAccountsEnabled) {
|
||||
return fxAccounts.getSignedInUser().then(user => {
|
||||
// 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");
|
||||
return fxAccounts.getSignedInUser().then(user => {
|
||||
// We want to treat "account needs verification" as "needs setup".
|
||||
return !(user && user.verified);
|
||||
});
|
||||
},
|
||||
|
||||
// Returns a promise that resolves with true if the user currently signed in
|
||||
// to Sync needs to be verified, false otherwise.
|
||||
_needsVerification() {
|
||||
// For callers who care about the distinction between "needs setup" and
|
||||
// "needs verification"
|
||||
if (this.weaveService.fxAccountsEnabled) {
|
||||
return fxAccounts.getSignedInUser().then(user => {
|
||||
// If there is no user, they can't be in a "needs verification" state.
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
return !user.verified;
|
||||
});
|
||||
}
|
||||
|
||||
// Otherwise we are configured for legacy Sync, which has no verification
|
||||
// concept.
|
||||
return Promise.resolve(false);
|
||||
return fxAccounts.getSignedInUser().then(user => {
|
||||
// If there is no user, they can't be in a "needs verification" state.
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
return !user.verified;
|
||||
});
|
||||
},
|
||||
|
||||
// Note that we don't show login errors in a notification bar here, but do
|
||||
|
@ -92,17 +92,6 @@ WeaveService.prototype = {
|
||||
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.
|
||||
*
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
@ -129,12 +129,6 @@ var TPS = {
|
||||
shouldValidateForms: false,
|
||||
|
||||
_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();
|
||||
|
||||
OBSERVER_TOPICS.forEach(function(aTopic) {
|
||||
@ -143,12 +137,7 @@ var TPS = {
|
||||
|
||||
// Configure some logging prefs for Sync itself.
|
||||
Weave.Svc.Prefs.set("log.appender.dump", "Debug");
|
||||
// Import the appropriate authentication module
|
||||
if (this.fxaccounts_enabled) {
|
||||
Cu.import("resource://tps/auth/fxaccounts.jsm", module);
|
||||
} else {
|
||||
Cu.import("resource://tps/auth/sync.jsm", module);
|
||||
}
|
||||
Cu.import("resource://tps/auth/fxaccounts.jsm", module);
|
||||
},
|
||||
|
||||
DumpError(msg, exc = null) {
|
||||
@ -860,7 +849,6 @@ var TPS = {
|
||||
Logger.logInfo("Firefox version: " + Services.appinfo.version);
|
||||
Logger.logInfo("Firefox source revision: " + (AppConstants.SOURCE_REVISION_URL || "unknown"));
|
||||
Logger.logInfo("Firefox platform: " + AppConstants.platform);
|
||||
Logger.logInfo("Firefox Accounts enabled: " + this.fxaccounts_enabled);
|
||||
|
||||
// do some sync housekeeping
|
||||
if (Weave.Service.isLoggedIn) {
|
||||
@ -1136,18 +1124,13 @@ var TPS = {
|
||||
}
|
||||
|
||||
Logger.logInfo("Setting client credentials and login.");
|
||||
let account = this.fxaccounts_enabled ? this.config.fx_account
|
||||
: this.config.sync_account;
|
||||
Authentication.signIn(account);
|
||||
Authentication.signIn(this.config.fx_account);
|
||||
this.waitForSetupComplete();
|
||||
Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK");
|
||||
this.waitForTracking();
|
||||
// If fxaccounts is enabled we get an initial sync at login time - let
|
||||
// that complete.
|
||||
if (this.fxaccounts_enabled) {
|
||||
this._triggeredSync = true;
|
||||
this.waitForSyncFinished();
|
||||
}
|
||||
// We get an initial sync at login time - let that complete.
|
||||
this._triggeredSync = true;
|
||||
this.waitForSyncFinished();
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user