mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1887739: Removes force_auth fxa path and uses connect path instead.r=markh,settings-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D208783
This commit is contained in:
parent
8843094dda
commit
612f797c4f
@ -1299,7 +1299,7 @@ var gSync = {
|
|||||||
if (!(await FxAccounts.canConnectAccount())) {
|
if (!(await FxAccounts.canConnectAccount())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const url = await FxAccounts.config.promiseForceSigninURI(entryPoint);
|
const url = await FxAccounts.config.promiseConnectAccountURI(entryPoint);
|
||||||
switchToTabHavingURI(url, true, {
|
switchToTabHavingURI(url, true, {
|
||||||
replaceQueryString: true,
|
replaceQueryString: true,
|
||||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||||
|
@ -449,17 +449,7 @@ var gSyncPane = {
|
|||||||
* different entrypoints to accounts
|
* different entrypoints to accounts
|
||||||
* */
|
* */
|
||||||
async reSignIn(entrypoint) {
|
async reSignIn(entrypoint) {
|
||||||
// There's a bit of an edge-case here - we might be forcing reauth when we've
|
const url = await FxAccounts.config.promiseConnectAccountURI(entrypoint);
|
||||||
// lost the FxA account data - in which case we'll not get a URL as the re-auth
|
|
||||||
// URL embeds account info and the server endpoint complains if we don't
|
|
||||||
// supply it - So we just use the regular "sign in" URL in that case.
|
|
||||||
if (!(await FxAccounts.canConnectAccount())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const url =
|
|
||||||
(await FxAccounts.config.promiseForceSigninURI(entrypoint)) ||
|
|
||||||
(await FxAccounts.config.promiseConnectAccountURI(entrypoint));
|
|
||||||
this.replaceTabWithUrl(url);
|
this.replaceTabWithUrl(url);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -78,14 +78,6 @@ export var FxAccountsConfig = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async promiseForceSigninURI(entrypoint, extraParams = {}) {
|
|
||||||
const authParams = await this._getAuthParams();
|
|
||||||
return this._buildURL("force_auth", {
|
|
||||||
extraParams: { entrypoint, ...authParams, ...extraParams },
|
|
||||||
addAccountIdentifiers: true,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
async promiseManageURI(entrypoint, extraParams = {}) {
|
async promiseManageURI(entrypoint, extraParams = {}) {
|
||||||
return this._buildURL("settings", {
|
return this._buildURL("settings", {
|
||||||
extraParams: { entrypoint, ...extraParams },
|
extraParams: { entrypoint, ...extraParams },
|
||||||
@ -186,7 +178,7 @@ export var FxAccountsConfig = {
|
|||||||
|
|
||||||
resetConfigURLs() {
|
resetConfigURLs() {
|
||||||
let autoconfigURL = this.getAutoConfigURL();
|
let autoconfigURL = this.getAutoConfigURL();
|
||||||
if (!autoconfigURL) {
|
if (autoconfigURL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// They have the autoconfig uri pref set, so we clear all the prefs that we
|
// They have the autoconfig uri pref set, so we clear all the prefs that we
|
||||||
|
@ -35,6 +35,7 @@ import {
|
|||||||
log,
|
log,
|
||||||
logPII,
|
logPII,
|
||||||
} from "resource://gre/modules/FxAccountsCommon.sys.mjs";
|
} from "resource://gre/modules/FxAccountsCommon.sys.mjs";
|
||||||
|
import { SyncDisconnect } from "resource://services-sync/SyncDisconnect.sys.mjs";
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
@ -471,6 +472,10 @@ FxAccountsWebChannelHelpers.prototype = {
|
|||||||
* @param accountData the user's account data and credentials
|
* @param accountData the user's account data and credentials
|
||||||
*/
|
*/
|
||||||
async login(accountData) {
|
async login(accountData) {
|
||||||
|
const signedInUser = await this._fxAccounts.getSignedInUser();
|
||||||
|
if (signedInUser) {
|
||||||
|
await this._disconnect();
|
||||||
|
}
|
||||||
// We don't act on customizeSync anymore, it used to open a dialog inside
|
// We don't act on customizeSync anymore, it used to open a dialog inside
|
||||||
// the browser to selecte the engines to sync but we do it on the web now.
|
// the browser to selecte the engines to sync but we do it on the web now.
|
||||||
log.debug("Webchannel is logging a user in.");
|
log.debug("Webchannel is logging a user in.");
|
||||||
@ -499,6 +504,7 @@ FxAccountsWebChannelHelpers.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
const xps = await this._initializeSync();
|
const xps = await this._initializeSync();
|
||||||
await this._fxAccounts._internal.setSignedInUser(accountData);
|
await this._fxAccounts._internal.setSignedInUser(accountData);
|
||||||
|
|
||||||
if (requestedServices) {
|
if (requestedServices) {
|
||||||
// User has enabled Sync.
|
// User has enabled Sync.
|
||||||
if (requestedServices.sync) {
|
if (requestedServices.sync) {
|
||||||
@ -511,6 +517,14 @@ FxAccountsWebChannelHelpers.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnects the user from Sync and FxA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
_disconnect() {
|
||||||
|
return SyncDisconnect.disconnect(false);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logins in to sync by completing an OAuth flow
|
* Logins in to sync by completing an OAuth flow
|
||||||
* @param { Object } oauthData: The oauth code and state as returned by the server */
|
* @param { Object } oauthData: The oauth code and state as returned by the server */
|
||||||
|
@ -469,6 +469,9 @@ add_test(function test_helpers_should_allow_relink_different_email() {
|
|||||||
add_task(async function test_helpers_login_without_customize_sync() {
|
add_task(async function test_helpers_login_without_customize_sync() {
|
||||||
let helpers = new FxAccountsWebChannelHelpers({
|
let helpers = new FxAccountsWebChannelHelpers({
|
||||||
fxAccounts: {
|
fxAccounts: {
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
_internal: {
|
_internal: {
|
||||||
setSignedInUser(accountData) {
|
setSignedInUser(accountData) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@ -512,6 +515,9 @@ add_task(async function test_helpers_login_without_customize_sync() {
|
|||||||
add_task(async function test_helpers_login_set_previous_account_name_hash() {
|
add_task(async function test_helpers_login_set_previous_account_name_hash() {
|
||||||
let helpers = new FxAccountsWebChannelHelpers({
|
let helpers = new FxAccountsWebChannelHelpers({
|
||||||
fxAccounts: {
|
fxAccounts: {
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
_internal: {
|
_internal: {
|
||||||
setSignedInUser() {
|
setSignedInUser() {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@ -549,6 +555,47 @@ add_task(async function test_helpers_login_set_previous_account_name_hash() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add_task(async function test_helpers_login_another_user_signed_in() {
|
||||||
|
let helpers = new FxAccountsWebChannelHelpers({
|
||||||
|
fxAccounts: {
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve({ uid: "foo" });
|
||||||
|
},
|
||||||
|
_internal: {
|
||||||
|
setSignedInUser(accountData) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
// ensure fxAccounts is informed of the new user being signed in.
|
||||||
|
Assert.equal(accountData.email, "testuser@testuser.com");
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
telemetry: {
|
||||||
|
recordConnection: sinon.spy(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
weaveXPCOM: {
|
||||||
|
whenLoaded() {},
|
||||||
|
Weave: {
|
||||||
|
Service: {
|
||||||
|
configure() {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
helpers._disconnect = sinon.spy();
|
||||||
|
|
||||||
|
await helpers.login({
|
||||||
|
email: "testuser@testuser.com",
|
||||||
|
verifiedCanLinkAccount: true,
|
||||||
|
customizeSync: false,
|
||||||
|
});
|
||||||
|
Assert.ok(
|
||||||
|
helpers._fxAccounts.telemetry.recordConnection.calledWith([], "webchannel")
|
||||||
|
);
|
||||||
|
Assert.ok(helpers._disconnect.called);
|
||||||
|
});
|
||||||
|
|
||||||
add_task(
|
add_task(
|
||||||
async function test_helpers_login_dont_set_previous_account_name_hash_for_unverified_emails() {
|
async function test_helpers_login_dont_set_previous_account_name_hash_for_unverified_emails() {
|
||||||
let helpers = new FxAccountsWebChannelHelpers({
|
let helpers = new FxAccountsWebChannelHelpers({
|
||||||
@ -565,6 +612,9 @@ add_task(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
telemetry: {
|
telemetry: {
|
||||||
recordConnection() {},
|
recordConnection() {},
|
||||||
},
|
},
|
||||||
@ -606,6 +656,9 @@ add_task(async function test_helpers_login_with_customize_sync() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
telemetry: {
|
telemetry: {
|
||||||
recordConnection: sinon.spy(),
|
recordConnection: sinon.spy(),
|
||||||
},
|
},
|
||||||
@ -648,6 +701,9 @@ add_task(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
telemetry: {
|
telemetry: {
|
||||||
recordConnection: sinon.spy(),
|
recordConnection: sinon.spy(),
|
||||||
},
|
},
|
||||||
@ -744,6 +800,9 @@ add_task(async function test_helpers_login_with_offered_sync_engines() {
|
|||||||
resolve(accountData);
|
resolve(accountData);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
telemetry: {
|
telemetry: {
|
||||||
recordConnection() {},
|
recordConnection() {},
|
||||||
},
|
},
|
||||||
@ -801,6 +860,9 @@ add_task(async function test_helpers_login_nothing_offered() {
|
|||||||
resolve(accountData);
|
resolve(accountData);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
getSignedInUser() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
telemetry: {
|
telemetry: {
|
||||||
recordConnection() {},
|
recordConnection() {},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user