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

Commit

Permalink
Fix reset password completion not generating an assertion.
Browse files Browse the repository at this point in the history
issue #1508
  • Loading branch information
Shane Tomlinson committed Apr 27, 2012
1 parent cdfd765 commit 3c5bb60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 7 additions & 2 deletions resources/static/dialog/resources/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,14 @@ BrowserID.State = (function() {
});

handleState("reset_password", function(msg, info) {
// reset password says the password has been reset, now waiting for
// confirmation.
info = info || {};
// reset password says the password user has confirmed that they want to
// reset their password. doResetPassword will attempt to call the
// call the create user wsapi call. If the wsapi call is successful,
// the user will be directed to the "go verify your account" message.

// We have to save off the staged email address here for when the user
// verifies their account and user_confirmed is called.
self.stagedEmail = info.email;
startAction(false, "doResetPassword", info);
});
Expand Down
16 changes: 13 additions & 3 deletions resources/static/test/cases/resources/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,31 @@
equal(actions.info.doForgotPassword.requiredEmail, true, "correct requiredEmail passed");
});

test("reset_password - call doResetPassword", function() {
// XXX how is this different from forgot_password?
test("reset_password to user_confirmed - call doResetPassword then doEmailConfirmed", function() {
// reset_password indicates the user has verified that they want to reset
// their password.
mediator.publish("reset_password", {
email: TEST_EMAIL
});
equal(actions.info.doResetPassword.email, TEST_EMAIL, "reset password with the correct email");

// At this point the user should be displayed the "go confirm your address"
// screen.

// user_confirmed means the user has confirmed their email and the dialog
// has received the "complete" message from /wsapi/user_creation_status
mediator.publish("user_confirmed");
equal(actions.info.doEmailConfirmed.email, TEST_EMAIL, "email successfully verified, doEmailConfirmed called with the correct email");
});


test("cancel reset_password flow - go two steps back", function() {
// we want to skip the "verify" screen of reset password and instead go two
// screens back. Do do this, we are simulating the steps necessary to get
// to the reset_password flow.
mediator.publish("authenticate");
mediator.publish("forgot_password", undefined, { email: TEST_EMAIL });
mediator.publish("reset_password");
mediator.publish("reset_password", { email: TEST_EMAIL });
actions.info.doAuthenticate = {};
mediator.publish("cancel_state");
equal(actions.info.doAuthenticate.email, TEST_EMAIL, "authenticate called with the correct email");
Expand Down

0 comments on commit 3c5bb60

Please sign in to comment.