Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1616 from mozilla/issue_1557_wrong_password_error
Browse files Browse the repository at this point in the history
show a tooltip when the user types a bad password in the add_email_address and verify_email_address screens.
  • Loading branch information
lloyd committed May 24, 2012
2 parents 0b6e4ed + 2c8ec53 commit 865684a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
11 changes: 10 additions & 1 deletion resources/static/pages/verify_secondary_address.js
Expand Up @@ -15,6 +15,7 @@ BrowserID.verifySecondaryAddress = (function() {
helpers = bid.Helpers,
complete = helpers.complete,
validation = bid.Validation,
tooltip = bid.Tooltip,
token,
sc,
needsPassword,
Expand Down Expand Up @@ -49,7 +50,15 @@ BrowserID.verifySecondaryAddress = (function() {

var selector = info.valid ? "#congrats" : "#cannotcomplete";
pageHelpers.replaceFormWithNotice(selector, complete.curry(oncomplete, info.valid));
}, pageHelpers.getFailure(errors.verifyEmail, oncomplete));
}, function(info) {
if (info.network && info.network.status === 401) {
tooltip.showTooltip("#cannot_authenticate");
complete(oncomplete, false);
}
else {
pageHelpers.showFailure(errors.verifyEmail, info, oncomplete);
}
});
}
else {
complete(oncomplete, false);
Expand Down
14 changes: 14 additions & 0 deletions resources/static/test/cases/pages/verify_secondary_address.js
Expand Up @@ -125,6 +125,20 @@
});
});

asyncTest("password: bad password", function() {
$("#password").val("password");

xhr.useResult("mustAuth");
createController(config, function() {
xhr.useResult("badPassword");
controller.submit(function(status) {
equal(status, false, "correct status");
testHelpers.testTooltipVisible();
start();
});
});
});

asyncTest("password: good password bad token", function() {
$("#password").val("password");

Expand Down
12 changes: 6 additions & 6 deletions resources/static/test/cases/shared/network.js
Expand Up @@ -174,9 +174,9 @@
}, testHelpers.unexpectedXHRFailure);
});

asyncTest("completeEmailRegistration with valid token, missing password", function() {
transport.useResult("missing_password");
network.completeEmailRegistration("token", undefined,
asyncTest("completeEmailRegistration with valid token, bad password", function() {
transport.useResult("badPassword");
network.completeEmailRegistration("token", "password",
testHelpers.unexpectedSuccess,
testHelpers.expectedXHRFailure);
});
Expand Down Expand Up @@ -280,9 +280,9 @@
}, testHelpers.unexpectedFailure);
});

asyncTest("completeUserRegistration with valid token, missing password", function() {
transport.useResult("missing_password");
network.completeUserRegistration("token", undefined,
asyncTest("completeUserRegistration with valid token, bad password", function() {
transport.useResult("badPassword");
network.completeUserRegistration("token", "password",
testHelpers.unexpectedSuccess,
testHelpers.expectedXHRFailure);
});
Expand Down
5 changes: 3 additions & 2 deletions resources/static/test/mocks/xhr.js
Expand Up @@ -40,6 +40,7 @@ BrowserID.Mocks.xhr = (function() {
"get /wsapi/email_for_token?token=token valid": { email: "testuser@testuser.com" },
"get /wsapi/email_for_token?token=token mustAuth": { email: "testuser@testuser.com", must_auth: true },
"get /wsapi/email_for_token?token=token needsPassword": { email: "testuser@testuser.com", needs_password: true },
"get /wsapi/email_for_token?token=token badPassword": { email: "testuser@testuser.com", must_auth: true },
"get /wsapi/email_for_token?token=token invalid": { success: false },
"post /wsapi/authenticate_user valid": { success: true, userid: 1 },
"post /wsapi/authenticate_user invalid": { success: false },
Expand All @@ -53,7 +54,7 @@ BrowserID.Mocks.xhr = (function() {
"post /wsapi/cert_key invalid": undefined,
"post /wsapi/cert_key ajaxError": undefined,
"post /wsapi/complete_email_addition valid": { success: true },
"post /wsapi/complete_email_addition missing_password": 401,
"post /wsapi/complete_email_addition badPassword": 401,
"post /wsapi/complete_email_addition invalid": { success: false },
"post /wsapi/complete_email_addition ajaxError": undefined,
"post /wsapi/stage_user unknown_secondary": { success: true },
Expand All @@ -67,7 +68,7 @@ BrowserID.Mocks.xhr = (function() {
"get /wsapi/user_creation_status?email=registered%40testuser.com noRegistration": { status: "noRegistration" },
"get /wsapi/user_creation_status?email=registered%40testuser.com ajaxError": undefined,
"post /wsapi/complete_user_creation valid": { success: true },
"post /wsapi/complete_user_creation missing_password": 401,
"post /wsapi/complete_user_creation badPassword": 401,
"post /wsapi/complete_user_creation invalid": { success: false },
"post /wsapi/complete_user_creation ajaxError": undefined,
"post /wsapi/logout valid": { success: true },
Expand Down
4 changes: 4 additions & 0 deletions resources/views/add_email_address.ejs
Expand Up @@ -30,6 +30,10 @@
<div class="tooltip" id="password_length" for="password">
<%= gettext('Password must be between 8 and 80 characters long.') %>
</div>

<div id="cannot_authenticate" class="tooltip" for="password">
<%= gettext('The account cannot be verified with this username and password.') %>
</div>
</li>

<li class="password_entry" id="verify_password">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/verify_email_address.ejs
Expand Up @@ -30,6 +30,10 @@
<div class="tooltip" id="password_length" for="password">
<%= gettext('Password must be between 8 and 80 characters long.') %>
</div>

<div id="cannot_authenticate" class="tooltip" for="password">
<%= gettext('The account cannot be verified with this username and password.') %>
</div>
</li>

<li class="password_entry" id="verify_password">
Expand Down

0 comments on commit 865684a

Please sign in to comment.