зеркало из https://github.com/mozilla/pjs.git
Bug 596620 - Remove compat code for username-based UI. r=rnewman
Also call Weave.Service.createAccount() with right parameters.
This commit is contained in:
Родитель
0d51da77db
Коммит
e00bebc750
|
@ -1,7 +1,5 @@
|
|||
error.login.reason.network = Failed to connect to the server
|
||||
error.login.reason.synckey = Wrong Sync Key
|
||||
# error.login.reason.password is deprecated.
|
||||
error.login.reason.password = Incorrect username or password
|
||||
error.login.reason.account = Incorrect account name or password
|
||||
error.login.reason.no_password= No saved password to use
|
||||
error.login.reason.no_synckey = No saved Sync Key to use
|
||||
|
|
|
@ -1184,12 +1184,6 @@ WeaveSvc.prototype = {
|
|||
|
||||
checkAccount: function checkAccount(account) {
|
||||
let username = this._usernameFromAccount(account);
|
||||
return this.checkUsername(username);
|
||||
},
|
||||
|
||||
// Backwards compat with the Firefox UI. Fold into checkAccount() once
|
||||
// bug 595066 has landed.
|
||||
checkUsername: function checkUsername(username) {
|
||||
let url = this.userAPI + username;
|
||||
let res = new Resource(url);
|
||||
res.authenticator = new NoOpAuthenticator();
|
||||
|
@ -1211,18 +1205,9 @@ WeaveSvc.prototype = {
|
|||
return this._errorStr(data);
|
||||
},
|
||||
|
||||
createAccount: function createAccount() {
|
||||
// Backwards compat with the Firefox UI. Change to signature to
|
||||
// (email, password, captchaChallenge, captchaResponse) once
|
||||
// bug 595066 has landed.
|
||||
let username, email, password, captchaChallenge, captchaResponse;
|
||||
if (arguments.length == 4) {
|
||||
[email, password, captchaChallenge, captchaResponse] = arguments;
|
||||
username = this._usernameFromAccount(email);
|
||||
} else {
|
||||
[username, password, email, captchaChallenge, captchaResponse] = arguments;
|
||||
}
|
||||
|
||||
createAccount: function createAccount(email, password,
|
||||
captchaChallenge, captchaResponse) {
|
||||
let username = this._usernameFromAccount(email);
|
||||
let payload = JSON.stringify({
|
||||
"password": Utils.encodeUTF8(password),
|
||||
"email": email,
|
||||
|
|
|
@ -15,7 +15,7 @@ function run_test() {
|
|||
Service.serverURL = "http://localhost:8080/";
|
||||
|
||||
_("A 404 will be recorded as 'generic-server-error'");
|
||||
do_check_eq(Service.checkUsername("jimdoe"), "generic-server-error");
|
||||
do_check_eq(Service.checkAccount("jimdoe"), "generic-server-error");
|
||||
|
||||
_("Account that's available.");
|
||||
do_check_eq(Service.checkAccount("john@doe.com"), "available");
|
||||
|
@ -23,13 +23,11 @@ function run_test() {
|
|||
_("Account that's not available.");
|
||||
do_check_eq(Service.checkAccount("jane@doe.com"), "notAvailable");
|
||||
|
||||
// Backwards compat with the Firefox UI. Remove once bug 595066 has landed.
|
||||
_("Username fallback: Account that's not available.");
|
||||
do_check_eq(Service.checkAccount("johndoe"), "notAvailable");
|
||||
|
||||
_("Account that's not available.");
|
||||
do_check_eq(Service.checkUsername("johndoe"), "notAvailable");
|
||||
|
||||
_("Account that's available.");
|
||||
do_check_eq(Service.checkUsername("janedoe"), "available");
|
||||
_("Username fallback: Account that's available.");
|
||||
do_check_eq(Service.checkAccount("janedoe"), "available");
|
||||
|
||||
} finally {
|
||||
Svc.Prefs.resetBranch("");
|
||||
|
|
|
@ -23,10 +23,7 @@ function run_test() {
|
|||
// jane@doe.com
|
||||
"/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": send(400, "Bad Request", "2"),
|
||||
// jim@doe.com
|
||||
"/user/1.0/vz6fhecgw5t3sgx3a4cektoiokyczkqd": send(500, "Server Error", "Server Error"),
|
||||
"/user/1.0/johndoe": send(200, "OK", "0"),
|
||||
"/user/1.0/janedoe": send(400, "Bad Request", "2"),
|
||||
"/user/1.0/jimdoe": send(500, "Server Error", "Server Error")
|
||||
"/user/1.0/vz6fhecgw5t3sgx3a4cektoiokyczkqd": send(500, "Server Error", "Server Error")
|
||||
});
|
||||
try {
|
||||
Service.serverURL = "http://localhost:8080/";
|
||||
|
@ -65,24 +62,6 @@ function run_test() {
|
|||
"challenge", "response");
|
||||
do_check_eq(secretHeader, "my-server-secret");
|
||||
|
||||
|
||||
// Backwards compat with the Firefox UI. Remove once bug 595066 has landed.
|
||||
|
||||
_("Create an old-style account.");
|
||||
res = Service.createAccount("johndoe", "mysecretpw", "john@doe.com",
|
||||
"challenge", "response");
|
||||
do_check_eq(res, null);
|
||||
|
||||
_("Invalid captcha or other user-friendly error.");
|
||||
res = Service.createAccount("janedoe", "anothersecretpw", "jane@doe.com",
|
||||
"challenge", "response");
|
||||
do_check_eq(res, "invalid-captcha");
|
||||
|
||||
_("Generic server error.");
|
||||
res = Service.createAccount("jimdoe", "preciousss", "jim@doe.com",
|
||||
"challenge", "response");
|
||||
do_check_eq(res, "generic-server-error");
|
||||
|
||||
} finally {
|
||||
Svc.Prefs.resetBranch("");
|
||||
server.stop(do_test_finished);
|
||||
|
|
|
@ -6,7 +6,7 @@ function run_test() {
|
|||
// we just test whether the returned string includes the
|
||||
// string "unknown", should be good enough
|
||||
|
||||
str = Utils.getErrorString("error.login.reason.password");
|
||||
str = Utils.getErrorString("error.login.reason.account");
|
||||
do_check_true(str.match(/unknown/i) == null);
|
||||
|
||||
str = Utils.getErrorString("foobar");
|
||||
|
|
Загрузка…
Ссылка в новой задаче