Skip to content
Snippets Groups Projects
Commit b27e9bb5 authored by Shane Tomlinson's avatar Shane Tomlinson Committed by Austin King
Browse files

When clicking "use another email address" after "reset password", send user...

When clicking "use another email address" after "reset password", send user back to authentication screen.

* Update the state machine to have a doResetPassword.
* If cancelling and the next state is doResetPassword, go back two steps to auth screen.
* When going to auth screen, print original email address.

issue #984
parent a3fef3c8
No related branches found
No related tags found
No related merge requests found
......@@ -100,6 +100,10 @@ BrowserID.Modules.Actions = (function() {
startService("forgot_password", info);
},
doResetPassword: function(info) {
this.doConfirmUser(info.email);
},
doConfirmEmail: function(email) {
startRegCheckService.call(this, email, "waitForEmailValidation", "email_confirmed");
},
......
......@@ -62,8 +62,8 @@
function popState(info) {
// Skip the first state, it is where the user is at now.
stateStack.pop();
var state = stateStack[stateStack.length - 1];
if (state) {
state.args[0] = state.args[0] || {};
_.extend(state.args[0], info);
......@@ -89,7 +89,6 @@
}
}
subscribe("offline", function(msg, info) {
startState("doOffline");
});
......@@ -152,14 +151,17 @@
subscribe("primary_user", function(msg, info) {
addPrimaryUser = !!info.add;
email = info.email;
// We don't want to put the provisioning step on the stack, instead when
// a user cancels this step, they should go back to the step before the
// provisioning.
updateCurrentStateInfo(info);
var idInfo = storage.getEmail(email);
if(idInfo && idInfo.cert) {
mediator.publish("primary_user_ready", info);
}
else {
// We don't want to put the provisioning step on the stack, instead when
// a user cancels this step, they should go back to the step before the
// provisioning.
startState(false, "doProvisionPrimaryUser", info);
}
});
......@@ -253,12 +255,15 @@
});
subscribe("forgot_password", function(msg, info) {
// forgot password initiates the forgotten password flow.
updateCurrentStateInfo(info);
startState("doForgotPassword", info);
});
subscribe("reset_password", function(msg, info) {
startState("doConfirmUser", info.email);
// reset password says the password has been reset, now waiting for
// confirmation.
startState(false, "doResetPassword", info);
});
subscribe("assertion_generated", function(msg, info) {
......
......@@ -139,12 +139,24 @@
equal(actions.info.doForgotPassword.requiredEmail, true, "correct requiredEmail passed");
});
test("reset_password", function() {
test("reset_password - call doResetPassword", function() {
// XXX how is this different from forgot_password?
mediator.publish("reset_password", {
email: "testuser@testuser.com"
});
equal(actions.info.doConfirmUser, "testuser@testuser.com", "reset password with the correct email");
equal(actions.info.doResetPassword.email, "testuser@testuser.com", "reset password 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", { email: "testuser@testuser.com" });
mediator.publish("reset_password");
actions.info.doAuthenticate = {};
mediator.publish("cancel_state");
equal(actions.info.doAuthenticate.email, "testuser@testuser.com", "authenticate called with the correct email");
});
test("assertion_generated with null assertion", function() {
......
......@@ -65,6 +65,9 @@ BrowserID.TestHelpers = (function() {
network.init();
storage.clear();
$("body").stop().show();
$("body")[0].className = "";
var el = $("#controller_head");
el.find("#formWrap .contents").html("");
el.find("#wait .contents").html("");
......@@ -81,6 +84,7 @@ BrowserID.TestHelpers = (function() {
provisioning: provisioning
});
user.setOrigin(testOrigin);
},
teardown: function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment