зеркало из https://github.com/mozilla/gecko-dev.git
Bug 981210 - FxAccountsManager.jsm and consumers: change "accountId" attribute to "email" r=jedp
This commit is contained in:
Родитель
58bef3b4fb
Коммит
ba8ef55ac1
|
@ -86,6 +86,11 @@ this.FxAccountsMgmtService = {
|
|||
if (!data) {
|
||||
return;
|
||||
}
|
||||
// Backwards compatibility: handle accountId coming from Gaia
|
||||
if (data.accountId && typeof(data.email === "undefined")) {
|
||||
data.email = data.accountId;
|
||||
delete data.accountId;
|
||||
}
|
||||
|
||||
switch(data.method) {
|
||||
case "getAccounts":
|
||||
|
@ -110,7 +115,7 @@ this.FxAccountsMgmtService = {
|
|||
).then(null, Components.utils.reportError);
|
||||
break;
|
||||
case "queryAccount":
|
||||
FxAccountsManager.queryAccount(data.accountId).then(
|
||||
FxAccountsManager.queryAccount(data.email).then(
|
||||
result => {
|
||||
self._onFulfill(msg.id, result);
|
||||
},
|
||||
|
@ -122,7 +127,7 @@ this.FxAccountsMgmtService = {
|
|||
case "signIn":
|
||||
case "signUp":
|
||||
case "refreshAuthentication":
|
||||
FxAccountsManager[data.method](data.accountId, data.password).then(
|
||||
FxAccountsManager[data.method](data.email, data.password).then(
|
||||
user => {
|
||||
self._onFulfill(msg.id, user);
|
||||
},
|
||||
|
|
|
@ -64,9 +64,9 @@ FxAccountsUIGlue.prototype = {
|
|||
return this._contentRequest("openFlow");
|
||||
},
|
||||
|
||||
refreshAuthentication: function(aAccountId) {
|
||||
refreshAuthentication: function(aEmail) {
|
||||
return this._contentRequest("refreshAuthentication", {
|
||||
accountId: aAccountId
|
||||
email: aEmail
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ add_test(function test_invalidEmailCase_signIn() {
|
|||
case "getAccounts":
|
||||
Services.obs.removeObserver(onMessage, "mozFxAccountsChromeEvent");
|
||||
|
||||
do_check_eq(message.data.accountId, canonicalEmail);
|
||||
do_check_eq(message.data.email, canonicalEmail);
|
||||
|
||||
do_test_finished();
|
||||
server.stop(run_next_test);
|
||||
|
@ -151,7 +151,7 @@ add_test(function test_invalidEmailCase_signIn() {
|
|||
id: "signIn",
|
||||
data: {
|
||||
method: "signIn",
|
||||
accountId: clientEmail,
|
||||
email: clientEmail,
|
||||
password: "123456",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -91,7 +91,7 @@ this.ERROR_INCORRECT_API_VERSION = "INCORRECT_API_VERSION";
|
|||
this.ERROR_INCORRECT_EMAIL_CASE = "INCORRECT_EMAIL_CASE";
|
||||
this.ERROR_INCORRECT_KEY_RETRIEVAL_METHOD = "INCORRECT_KEY_RETRIEVAL_METHOD";
|
||||
this.ERROR_INCORRECT_LOGIN_METHOD = "INCORRECT_LOGIN_METHOD";
|
||||
this.ERROR_INVALID_ACCOUNTID = "INVALID_ACCOUNTID";
|
||||
this.ERROR_INVALID_EMAIL = "INVALID_EMAIL";
|
||||
this.ERROR_INVALID_AUDIENCE = "INVALID_AUDIENCE";
|
||||
this.ERROR_INVALID_AUTH_TOKEN = "INVALID_AUTH_TOKEN";
|
||||
this.ERROR_INVALID_AUTH_TIMESTAMP = "INVALID_AUTH_TIMESTAMP";
|
||||
|
|
|
@ -55,7 +55,7 @@ this.FxAccountsManager = {
|
|||
}
|
||||
|
||||
return {
|
||||
accountId: this._activeSession.email,
|
||||
email: this._activeSession.email,
|
||||
verified: this._activeSession.verified
|
||||
}
|
||||
},
|
||||
|
@ -93,13 +93,13 @@ this.FxAccountsManager = {
|
|||
return this._fxAccounts.getAccountsClient();
|
||||
},
|
||||
|
||||
_signInSignUp: function(aMethod, aAccountId, aPassword) {
|
||||
_signInSignUp: function(aMethod, aEmail, aPassword) {
|
||||
if (Services.io.offline) {
|
||||
return this._error(ERROR_OFFLINE);
|
||||
}
|
||||
|
||||
if (!aAccountId) {
|
||||
return this._error(ERROR_INVALID_ACCOUNTID);
|
||||
if (!aEmail) {
|
||||
return this._error(ERROR_INVALID_EMAIL);
|
||||
}
|
||||
|
||||
if (!aPassword) {
|
||||
|
@ -121,7 +121,7 @@ this.FxAccountsManager = {
|
|||
user: this._user
|
||||
});
|
||||
}
|
||||
return client[aMethod](aAccountId, aPassword);
|
||||
return client[aMethod](aEmail, aPassword);
|
||||
}
|
||||
).then(
|
||||
user => {
|
||||
|
@ -135,7 +135,7 @@ this.FxAccountsManager = {
|
|||
// If the user object includes an email field, it may differ in
|
||||
// capitalization from what we sent down. This is the server's
|
||||
// canonical capitalization and should be used instead.
|
||||
user.email = user.email || aAccountId;
|
||||
user.email = user.email || aEmail;
|
||||
return this._fxAccounts.setSignedInUser(user).then(
|
||||
() => {
|
||||
this._activeSession = user;
|
||||
|
@ -226,12 +226,12 @@ this.FxAccountsManager = {
|
|||
|
||||
// -- API --
|
||||
|
||||
signIn: function(aAccountId, aPassword) {
|
||||
return this._signInSignUp("signIn", aAccountId, aPassword);
|
||||
signIn: function(aEmail, aPassword) {
|
||||
return this._signInSignUp("signIn", aEmail, aPassword);
|
||||
},
|
||||
|
||||
signUp: function(aAccountId, aPassword) {
|
||||
return this._signInSignUp("signUp", aAccountId, aPassword);
|
||||
signUp: function(aEmail, aPassword) {
|
||||
return this._signInSignUp("signUp", aEmail, aPassword);
|
||||
},
|
||||
|
||||
signOut: function() {
|
||||
|
@ -286,20 +286,20 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
queryAccount: function(aAccountId) {
|
||||
log.debug("queryAccount " + aAccountId);
|
||||
queryAccount: function(aEmail) {
|
||||
log.debug("queryAccount " + aEmail);
|
||||
if (Services.io.offline) {
|
||||
return this._error(ERROR_OFFLINE);
|
||||
}
|
||||
|
||||
let deferred = Promise.defer();
|
||||
|
||||
if (!aAccountId) {
|
||||
return this._error(ERROR_INVALID_ACCOUNTID);
|
||||
if (!aEmail) {
|
||||
return this._error(ERROR_INVALID_EMAIL);
|
||||
}
|
||||
|
||||
let client = this._getFxAccountsClient();
|
||||
return client.accountExists(aAccountId).then(
|
||||
return client.accountExists(aEmail).then(
|
||||
result => {
|
||||
log.debug("Account " + result ? "" : "does not" + " exists");
|
||||
let error = this._getError(result);
|
||||
|
@ -398,7 +398,7 @@ this.FxAccountsManager = {
|
|||
// will return the assertion. Otherwise, we will return an error.
|
||||
this._refreshing = true;
|
||||
return this._uiRequest(UI_REQUEST_REFRESH_AUTH,
|
||||
aAudience, user.accountId).then(
|
||||
aAudience, user.email).then(
|
||||
(assertion) => {
|
||||
this._refreshing = false;
|
||||
return assertion;
|
||||
|
|
|
@ -11,5 +11,5 @@ interface nsIFxAccountsUIGlue : nsISupports
|
|||
jsval signInFlow();
|
||||
|
||||
// Returns a Promise.
|
||||
jsval refreshAuthentication(in DOMString accountId);
|
||||
jsval refreshAuthentication(in DOMString email);
|
||||
};
|
||||
|
|
|
@ -412,7 +412,7 @@ add_test(function(test_getAccount_existing_verified_session) {
|
|||
FxAccountsManager.getAccount().then(
|
||||
result => {
|
||||
do_check_false(FxAccountsManager._fxAccounts._getSignedInUserCalled);
|
||||
do_check_eq(result.accountId, FxAccountsManager._user.accountId);
|
||||
do_check_eq(result.email, FxAccountsManager._user.email);
|
||||
do_check_eq(result.verified, FxAccountsManager._user.verified);
|
||||
run_next_test();
|
||||
},
|
||||
|
@ -430,7 +430,7 @@ add_test(function(test_getAccount_existing_unverified_session_unverified_user) {
|
|||
result => {
|
||||
do_check_true(FakeFxAccountsClient._recoveryEmailStatusCalled);
|
||||
do_check_false(result.verified);
|
||||
do_check_eq(result.accountId, FxAccountsManager._user.accountId);
|
||||
do_check_eq(result.email, FxAccountsManager._user.email);
|
||||
FakeFxAccountsClient._reset();
|
||||
run_next_test();
|
||||
},
|
||||
|
@ -451,7 +451,7 @@ add_test(function(test_getAccount_existing_unverified_session_verified_user) {
|
|||
FxAccountsManager.getAccount().then(
|
||||
result => {
|
||||
do_check_true(result.verified);
|
||||
do_check_eq(result.accountId, FxAccountsManager._user.accountId);
|
||||
do_check_eq(result.email, FxAccountsManager._user.email);
|
||||
FakeFxAccountsClient._reset();
|
||||
run_next_test();
|
||||
});
|
||||
|
@ -474,34 +474,34 @@ add_test(function(test_signOut) {
|
|||
);
|
||||
});
|
||||
|
||||
add_test(function(test_signUp_no_accountId) {
|
||||
do_print("= signUp, no accountId=");
|
||||
add_test(function(test_signUp_no_email) {
|
||||
do_print("= signUp, no email=");
|
||||
FxAccountsManager.signUp().then(
|
||||
() => {
|
||||
do_throw("Unexpected success");
|
||||
},
|
||||
error => {
|
||||
do_check_eq(error.error, ERROR_INVALID_ACCOUNTID);
|
||||
do_check_eq(error.error, ERROR_INVALID_EMAIL);
|
||||
run_next_test();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function(test_signIn_no_accountId) {
|
||||
do_print("= signIn, no accountId=");
|
||||
add_test(function(test_signIn_no_email) {
|
||||
do_print("= signIn, no email=");
|
||||
FxAccountsManager.signIn().then(
|
||||
() => {
|
||||
do_throw("Unexpected success");
|
||||
},
|
||||
error => {
|
||||
do_check_eq(error.error, ERROR_INVALID_ACCOUNTID);
|
||||
do_check_eq(error.error, ERROR_INVALID_EMAIL);
|
||||
run_next_test();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function(test_signUp_no_password) {
|
||||
do_print("= signUp, no accountId=");
|
||||
do_print("= signUp, no email=");
|
||||
FxAccountsManager.signUp("user@domain.org").then(
|
||||
() => {
|
||||
do_throw("Unexpected success");
|
||||
|
@ -513,8 +513,8 @@ add_test(function(test_signUp_no_password) {
|
|||
);
|
||||
});
|
||||
|
||||
add_test(function(test_signIn_no_accountId) {
|
||||
do_print("= signIn, no accountId=");
|
||||
add_test(function(test_signIn_no_email) {
|
||||
do_print("= signIn, no email=");
|
||||
FxAccountsManager.signIn("user@domain.org").then(
|
||||
() => {
|
||||
do_throw("Unexpected success");
|
||||
|
@ -537,7 +537,7 @@ add_test(function(test_signUp) {
|
|||
do_check_eq(FxAccountsManager._fxAccounts._signedInUser.email, "user@domain.org");
|
||||
do_check_eq(FakeFxAccountsClient._password, "password");
|
||||
do_check_true(result.accountCreated);
|
||||
do_check_eq(result.user.accountId, "user@domain.org");
|
||||
do_check_eq(result.user.email, "user@domain.org");
|
||||
do_check_false(result.user.verified);
|
||||
FakeFxAccountsClient._reset();
|
||||
FxAccountsManager._fxAccounts._reset();
|
||||
|
@ -558,7 +558,7 @@ add_test(function(test_signUp_already_signed_user) {
|
|||
error => {
|
||||
do_check_false(FakeFxAccountsClient._signInCalled);
|
||||
do_check_eq(error.error, ERROR_ALREADY_SIGNED_IN_USER);
|
||||
do_check_eq(error.details.user.accountId, "user@domain.org");
|
||||
do_check_eq(error.details.user.email, "user@domain.org");
|
||||
do_check_false(error.details.user.verified);
|
||||
run_next_test();
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ add_test(function(test_signIn_already_signed_user) {
|
|||
},
|
||||
error => {
|
||||
do_check_eq(error.error, ERROR_ALREADY_SIGNED_IN_USER);
|
||||
do_check_eq(error.details.user.accountId, "user@domain.org");
|
||||
do_check_eq(error.details.user.email, "user@domain.org");
|
||||
do_check_false(error.details.user.verified);
|
||||
run_next_test();
|
||||
}
|
||||
|
@ -633,14 +633,14 @@ add_test(function(test_queryAccount_exists) {
|
|||
);
|
||||
});
|
||||
|
||||
add_test(function(test_queryAccount_no_accountId) {
|
||||
do_print("= queryAccount, no accountId =");
|
||||
add_test(function(test_queryAccount_no_email) {
|
||||
do_print("= queryAccount, no email =");
|
||||
FxAccountsManager.queryAccount().then(
|
||||
() => {
|
||||
do_throw("Unexpected success");
|
||||
},
|
||||
error => {
|
||||
do_check_eq(error.error, ERROR_INVALID_ACCOUNTID);
|
||||
do_check_eq(error.error, ERROR_INVALID_EMAIL);
|
||||
run_next_test();
|
||||
}
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче