diff --git a/resources/static/dialog/js/misc/helpers.js b/resources/static/dialog/js/misc/helpers.js index d35b68a0ee9d97237278f4bcdcf3db6bab8d7f25..28c480aba491deef7cd0a59e234ff291829b8f6d 100644 --- a/resources/static/dialog/js/misc/helpers.js +++ b/resources/static/dialog/js/misc/helpers.js @@ -89,7 +89,7 @@ var self=this; user.requestPasswordReset(email, password, function(status) { if (status.success) { - self.publish("password_reset_staged", { email: email }); + self.publish("reset_password_staged", { email: email }); } else { tooltip.showTooltip("#could_not_add"); diff --git a/resources/static/dialog/js/misc/state.js b/resources/static/dialog/js/misc/state.js index cc52fa840d0195b964d7c0d4a752949b403f7edf..41dae826137bba102a7e57f03304784620b11626 100644 --- a/resources/static/dialog/js/misc/state.js +++ b/resources/static/dialog/js/misc/state.js @@ -348,7 +348,13 @@ BrowserID.State = (function() { // The unverified email has been staged, now the user has to confirm // ownership of the address. Send them off to the "verify your address" // screen. - startAction("doConfirmReverifyEmail"); + var actionInfo = { + email: info.email, + siteName: self.siteName + }; + + self.stagedEmail = info.email; + startAction("doConfirmReverifyEmail", actionInfo); }); handleState("email_valid_and_ready", function(msg, info) { @@ -394,38 +400,20 @@ BrowserID.State = (function() { handleState("forgot_password", function(msg, info) { // User has forgotten their password, let them reset it. The response // message from the forgot_password controller will be a set_password. - // the set_password handler needs to know the forgotPassword email so it - // knows how to handle the password being set. When the password is - // finally reset, the password_reset message will be raised where we must - // await email confirmation. + // the set_password handler needs to know the resetPasswordEmail so it + // knows how to trigger the reset_password_staged message. At this + // point, the email confirmation screen will be shown. self.resetPasswordEmail = info.email; startAction(false, "doForgotPassword", info); }); - handleState("stage_reset_password", function(msg, info) { - // reset_password says the user has confirmed that they want to - // reset their password. doStageResetPassword will attempt to invoke - // the reset_password wsapi. If the wsapi call is successful, - // the password_reset_staged message will be triggered and 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; - - var actionInfo = { - email: info.email, - password: info.password - }; - startAction(false, "doStageResetPassword", actionInfo); - }); - - handleState("password_reset_staged", function(msg, info) { + handleState("reset_password_staged", function(msg, info) { var actionInfo = { email: info.email, siteName: self.siteName }; + self.stagedEmail = info.email; startAction("doConfirmResetPassword", actionInfo); }); diff --git a/resources/static/dialog/js/modules/actions.js b/resources/static/dialog/js/modules/actions.js index 711f21bc9951364f21b160f11686f105c8b2c7e7..1ef5520eeeb0ee55ce04f6cf81ad0af20d1b7f29 100644 --- a/resources/static/dialog/js/modules/actions.js +++ b/resources/static/dialog/js/modules/actions.js @@ -32,11 +32,11 @@ BrowserID.Modules.Actions = (function() { return module; } - function startRegCheckService(options, verifier, message, password) { + function startRegCheckService(options, verifier, message) { var controller = startService("check_registration", { verifier: verifier, verificationMessage: message, - password: password, + password: options.password, siteName: options.siteName, email: options.email }); @@ -70,7 +70,7 @@ BrowserID.Modules.Actions = (function() { }, doConfirmUser: function(info) { - startRegCheckService.call(this, info, "waitForUserValidation", "user_confirmed", info.password || undefined); + startRegCheckService.call(this, info, "waitForUserValidation", "user_confirmed"); }, doPickEmail: function(info) { @@ -106,8 +106,7 @@ BrowserID.Modules.Actions = (function() { }, doConfirmResetPassword: function(info) { - startRegCheckService.call(this, info, "waitForPasswordResetComplete", "staged_address_confirmed", info.password || undefined); - + startRegCheckService.call(this, info, "waitForPasswordResetComplete", "staged_address_confirmed"); }, doStageReverifyEmail: function(info) { @@ -115,7 +114,7 @@ BrowserID.Modules.Actions = (function() { }, doConfirmReverifyEmail: function(info) { - startRegCheckService.call(this, info, "waitForEmailReverifyComplete", "staged_address_confirmed", info.password || undefined); + startRegCheckService.call(this, info, "waitForEmailReverifyComplete", "staged_address_confirmed"); }, doAssertionGenerated: function(info) { diff --git a/resources/static/test/cases/dialog/js/misc/state.js b/resources/static/test/cases/dialog/js/misc/state.js index 86f919450f623b4f3b68f6d2abbba48d4a28528b..5aee59a3127f7ce9b75e1e796a2f0c1a2496ee7c 100644 --- a/resources/static/test/cases/dialog/js/misc/state.js +++ b/resources/static/test/cases/dialog/js/misc/state.js @@ -43,7 +43,7 @@ } function testAddressStaged(startMessage, expectedAction) { - // password_reset_staged indicates the user has verified that they want to reset + // reset_password_staged indicates the user has verified that they want to reset // their password. mediator.publish(startMessage, { email: TEST_EMAIL @@ -55,15 +55,13 @@ // user_confirmed means the user has confirmed their email and the dialog // has received the "complete" message from /wsapi/user_creation_status. - try { - mediator.publish("staged_address_confirmed"); - } catch(e) { - // Exception is expected because as part of the user confirmation - // process, before user_confirmed is called, email addresses are synced. - // Addresses are not synced in this test. - equal(e.toString(), "invalid email", "expected failure"); - } + mediator.subscribe("email_chosen", function(msg, info) { + equal(info.email, TEST_EMAIL, "email_chosen triggered with the correct email"); + start(); + }); + storage.addSecondaryEmail(TEST_EMAIL, { unverified: true }); + mediator.publish("staged_address_confirmed"); } @@ -170,7 +168,7 @@ ok(actions.info.doRPInfo.privacyPolicy, "doRPInfo called with privacyPolicy set"); }); - test("user_staged - call doConfirmUser", function() { + asyncTest("user_staged - call doConfirmUser", function() { testAddressStaged("user_staged", "doConfirmUser"); }); @@ -198,7 +196,7 @@ } }); - test("email_staged - call doConfirmEmail", function() { + asyncTest("email_staged - call doConfirmEmail", function() { testAddressStaged("email_staged", "doConfirmEmail"); }); @@ -302,8 +300,8 @@ testActionStarted("doForgotPassword", { email: TEST_EMAIL, requiredEmail: true }); }); - test("password_reset_staged to staged_address_confirmed - call doConfirmResetPassword then doEmailConfirmed", function() { - testAddressStaged("password_reset_staged", "doConfirmResetPassword"); + asyncTest("reset_password_staged to staged_address_confirmed - call doConfirmResetPassword then doEmailConfirmed", function() { + testAddressStaged("reset_password_staged", "doConfirmResetPassword"); }); @@ -474,6 +472,10 @@ testReverifyEmailChosen("assertion"); }); + asyncTest("reverify_email_staged - call doConfirmReverifyEmail", function() { + testAddressStaged("reverify_email_staged", "doConfirmReverifyEmail"); + }); + test("email_chosen with primary email - call doProvisionPrimaryUser", function() { // If the email is a primary, throw the user down the primary flow. // Doing so will catch cases where the primary certificate is expired diff --git a/resources/static/test/cases/dialog/js/modules/actions.js b/resources/static/test/cases/dialog/js/modules/actions.js index 15f76f52ceebe272cb6d7dc7c5a144da05579ee5..48511c7c9e14cfadd6fcc75ea556e37bd3e40b98 100644 --- a/resources/static/test/cases/dialog/js/modules/actions.js +++ b/resources/static/test/cases/dialog/js/modules/actions.js @@ -119,8 +119,8 @@ testActionStartsModule('doForgotPassword', { email: TEST_EMAIL }, "set_password"); }); - asyncTest("doStageResetPassword - trigger password_reset_staged", function() { - testStageAddress("doStageResetPassword", "password_reset_staged"); + asyncTest("doStageResetPassword - trigger reset_password_staged", function() { + testStageAddress("doStageResetPassword", "reset_password_staged"); }); asyncTest("doConfirmResetPassword - start the check_registration service", function() {