Bug 1070115 - pass the uid and email address of the current FxA user to the account manage url. r=zaach

This commit is contained in:
Mark Hammond 2015-04-24 10:51:20 +10:00
parent 1875df6a47
commit 8a61e04761
3 changed files with 35 additions and 4 deletions

View File

@ -573,8 +573,12 @@ let gSyncPane = {
},
manageFirefoxAccount: function() {
let url = Services.prefs.getCharPref("identity.fxaccounts.settings.uri");
this.openContentInBrowser(url);
fxAccounts.promiseAccountsManageURI()
.then(url => {
this.openContentInBrowser(url, {
replaceQueryString: true
});
});
},
verifyFirefoxAccount: function() {

View File

@ -405,8 +405,12 @@ let gSyncPane = {
},
manageFirefoxAccount: function() {
let url = Services.prefs.getCharPref("identity.fxaccounts.settings.uri");
this.openContentInBrowser(url);
fxAccounts.promiseAccountsManageURI()
.then(url => {
this.openContentInBrowser(url, {
replaceQueryString: true
});
});
},
verifyFirefoxAccount: function() {

View File

@ -45,6 +45,7 @@ let publicProperties = [
"now",
"promiseAccountsForceSigninURI",
"promiseAccountsChangeProfileURI",
"promiseAccountsManageURI",
"removeCachedOAuthToken",
"resendVerificationEmail",
"setSignedInUser",
@ -1217,6 +1218,28 @@ FxAccountsInternal.prototype = {
}).then(result => currentState.resolve(result));
},
// Returns a promise that resolves with the URL to use to manage the current
// user's FxA acct.
promiseAccountsManageURI: function() {
let url = Services.urlFormatter.formatURLPref("identity.fxaccounts.settings.uri");
if (this._requireHttps() && !/^https:/.test(url)) { // Comment to un-break emacs js-mode highlighting
throw new Error("Firefox Accounts server must use HTTPS");
}
let currentState = this.currentAccountState;
// but we need to append the uid and email address onto a query string
// (if the server has no matching uid it will offer to sign in with the
// email address)
return this.getSignedInUser().then(accountData => {
if (!accountData) {
return null;
}
let newQueryPortion = url.indexOf("?") == -1 ? "?" : "&";
newQueryPortion += "uid=" + encodeURIComponent(accountData.uid) +
"&email=" + encodeURIComponent(accountData.email);
return url + newQueryPortion;
}).then(result => currentState.resolve(result));
},
/**
* Get an OAuth token for the user
*