Bug 596620 - Remove compat code for username-based UI. r=rnewman

Also call Weave.Service.createAccount() with right parameters.
This commit is contained in:
Philipp von Weitershausen 2011-03-25 00:57:23 -07:00
Родитель 4a1ded006f
Коммит 07ccf6df79
5 изменённых файлов: 10 добавлений и 50 удалений

Просмотреть файл

@ -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");