зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1792550 - ensure the primary password is unlocked before signing in to sync. r=Mardak,sfoster
Differential Revision: https://phabricator.services.mozilla.com/D158719
This commit is contained in:
Родитель
1225e9b8e7
Коммит
36b2282d01
|
@ -1142,6 +1142,9 @@ var gSync = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async openSignInAgainPage(entryPoint) {
|
async openSignInAgainPage(entryPoint) {
|
||||||
|
if (!(await FxAccounts.canConnectAccount())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = await FxAccounts.config.promiseForceSigninURI(entryPoint);
|
const url = await FxAccounts.config.promiseForceSigninURI(entryPoint);
|
||||||
switchToTabHavingURI(url, true, {
|
switchToTabHavingURI(url, true, {
|
||||||
replaceQueryString: true,
|
replaceQueryString: true,
|
||||||
|
@ -1198,6 +1201,9 @@ var gSync = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async openFxAEmailFirstPage(entryPoint) {
|
async openFxAEmailFirstPage(entryPoint) {
|
||||||
|
if (!(await FxAccounts.canConnectAccount())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = await FxAccounts.config.promiseConnectAccountURI(entryPoint);
|
const url = await FxAccounts.config.promiseConnectAccountURI(entryPoint);
|
||||||
switchToTabHavingURI(url, true, { replaceQueryString: true });
|
switchToTabHavingURI(url, true, { replaceQueryString: true });
|
||||||
},
|
},
|
||||||
|
|
|
@ -532,6 +532,9 @@ export const TabsSetupFlowManager = new (class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async openFxASignup(window) {
|
async openFxASignup(window) {
|
||||||
|
if (!(await lazy.fxAccounts.constructor.canConnectAccount())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = await lazy.fxAccounts.constructor.config.promiseConnectAccountURI(
|
const url = await lazy.fxAccounts.constructor.config.promiseConnectAccountURI(
|
||||||
"firefoxview"
|
"firefoxview"
|
||||||
);
|
);
|
||||||
|
|
|
@ -897,6 +897,9 @@ var gMainPane = {
|
||||||
win.openTrustedLinkIn("about:preferences#sync", "current");
|
win.openTrustedLinkIn("about:preferences#sync", "current");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(await FxAccounts.canConnectAccount())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let url = await FxAccounts.config.promiseConnectAccountURI(
|
let url = await FxAccounts.config.promiseConnectAccountURI(
|
||||||
"dev-edition-setup"
|
"dev-edition-setup"
|
||||||
);
|
);
|
||||||
|
|
|
@ -445,6 +445,9 @@ var gSyncPane = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async signIn() {
|
async signIn() {
|
||||||
|
if (!(await FxAccounts.canConnectAccount())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = await FxAccounts.config.promiseConnectAccountURI(
|
const url = await FxAccounts.config.promiseConnectAccountURI(
|
||||||
this._getEntryPoint()
|
this._getEntryPoint()
|
||||||
);
|
);
|
||||||
|
@ -456,6 +459,10 @@ var gSyncPane = {
|
||||||
// lost the FxA account data - in which case we'll not get a URL as the re-auth
|
// 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
|
// 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.
|
// supply it - So we just use the regular "sign in" URL in that case.
|
||||||
|
if (!(await FxAccounts.canConnectAccount())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let entryPoint = this._getEntryPoint();
|
let entryPoint = this._getEntryPoint();
|
||||||
const url =
|
const url =
|
||||||
(await FxAccounts.config.promiseForceSigninURI(entryPoint)) ||
|
(await FxAccounts.config.promiseForceSigninURI(entryPoint)) ||
|
||||||
|
|
|
@ -457,6 +457,13 @@ var UITour = {
|
||||||
case "showFirefoxAccounts": {
|
case "showFirefoxAccounts": {
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
return lazy.FxAccounts.canConnectAccount();
|
||||||
|
})
|
||||||
|
.then(canConnect => {
|
||||||
|
if (!canConnect) {
|
||||||
|
lazy.log.warn("showFirefoxAccounts: can't currently connect");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return data.email
|
return data.email
|
||||||
? lazy.FxAccounts.config.promiseEmailURI(
|
? lazy.FxAccounts.config.promiseEmailURI(
|
||||||
data.email,
|
data.email,
|
||||||
|
@ -467,6 +474,9 @@ var UITour = {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.then(uri => {
|
.then(uri => {
|
||||||
|
if (!uri) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = new URL(uri);
|
const url = new URL(uri);
|
||||||
// Call our helper to validate extraURLParams and populate URLSearchParams
|
// Call our helper to validate extraURLParams and populate URLSearchParams
|
||||||
if (!this._populateURLParams(url, data.extraURLParams)) {
|
if (!this._populateURLParams(url, data.extraURLParams)) {
|
||||||
|
|
|
@ -89,6 +89,15 @@ ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/FxAccountsTelemetry.jsm"
|
"resource://gre/modules/FxAccountsTelemetry.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyGetter(lazy, "mpLocked", () => {
|
||||||
|
return ChromeUtils.import("resource://services-sync/util.js").Utils.mpLocked;
|
||||||
|
});
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyGetter(lazy, "ensureMPUnlocked", () => {
|
||||||
|
return ChromeUtils.import("resource://services-sync/util.js").Utils
|
||||||
|
.ensureMPUnlocked;
|
||||||
|
});
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||||
Preferences: "resource://gre/modules/Preferences.jsm",
|
Preferences: "resource://gre/modules/Preferences.jsm",
|
||||||
});
|
});
|
||||||
|
@ -629,6 +638,23 @@ class FxAccounts {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns a promise that resolves to true if we can currently connect (ie,
|
||||||
|
* sign in, or re-connect after a password change) to a Firefox Account.
|
||||||
|
* If this returns false, the caller can assume that some UI was shown
|
||||||
|
* which tells the user why we could not connect.
|
||||||
|
*
|
||||||
|
* Currently, the primary password being locked is the only reason why
|
||||||
|
* this returns false, and in this scenario, the primary password unlock
|
||||||
|
* dialog will have been shown.
|
||||||
|
*
|
||||||
|
* This currently doesn't need to return a promise, but does so that
|
||||||
|
* future enhancements, such as other explanatory UI which requires
|
||||||
|
* async can work without modification of the call-sites.
|
||||||
|
*/
|
||||||
|
static canConnectAccount() {
|
||||||
|
return Promise.resolve(!lazy.mpLocked() || lazy.ensureMPUnlocked());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to a set of devices in the same account
|
* Send a message to a set of devices in the same account
|
||||||
*
|
*
|
||||||
|
|
|
@ -307,6 +307,9 @@ const SpecialMessageActions = {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "SHOW_FIREFOX_ACCOUNTS":
|
case "SHOW_FIREFOX_ACCOUNTS":
|
||||||
|
if (!(await lazy.FxAccounts.canConnectAccount())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
const data = action.data;
|
const data = action.data;
|
||||||
const url = await lazy.FxAccounts.config.promiseConnectAccountURI(
|
const url = await lazy.FxAccounts.config.promiseConnectAccountURI(
|
||||||
(data && data.entrypoint) || "snippets",
|
(data && data.entrypoint) || "snippets",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче