diff --git a/resources/static/dialog/resources/state.js b/resources/static/dialog/resources/state.js index 126e68878274f2fe717617c23c50be583386544e..c741014335fa105a7696cc02d44df7a163a46b0f 100644 --- a/resources/static/dialog/resources/state.js +++ b/resources/static/dialog/resources/state.js @@ -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 user has confirmed that they want to + // reset their password. doResetPassword will attempt to invoke + // the create_user wsapi. If the wsapi call is successful, + // the user will be shown the "go verify your account" message. + + // We have to save 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); }); diff --git a/resources/static/test/cases/resources/state.js b/resources/static/test/cases/resources/state.js index b620cdf598dbe85f3965123ff82e95e598c1a551..c8b818aa18d39f9d08b87bcfdfb300b3f2f0743b 100644 --- a/resources/static/test/cases/resources/state.js +++ b/resources/static/test/cases/resources/state.js @@ -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");