diff --git a/resources/static/pages/js/forgot.js b/resources/static/pages/js/forgot.js index 5d7c9385355f1dbc1eca1ff0bf85b826b867997e..4d59778a1d04abdd9fff0dd41d580b15f208a985 100644 --- a/resources/static/pages/js/forgot.js +++ b/resources/static/pages/js/forgot.js @@ -28,7 +28,7 @@ BrowserID.forgot = (function() { if (email && validPass) { user.requestPasswordReset(email, pass, function onSuccess(info) { if (info.success) { - pageHelpers.emailSent(oncomplete); + pageHelpers.emailSent("waitForPasswordResetComplete", oncomplete); } else { var tooltipEl = info.reason === "throttle" ? "#could_not_add" : "#not_registered"; diff --git a/resources/static/pages/js/page_helpers.js b/resources/static/pages/js/page_helpers.js index 9ec528c6b0103bdf4ebbfbb7bde50f75eb7cb139..c43ed717f48fe3b7bdb6ac107a81b6a0c565429b 100644 --- a/resources/static/pages/js/page_helpers.js +++ b/resources/static/pages/js/page_helpers.js @@ -68,7 +68,7 @@ BrowserID.PageHelpers = (function() { function getFailure(error, callback) { return function onFailure(info) { showFailure(error, info, callback); - } + }; } function replaceFormWithNotice(selector, onComplete) { @@ -88,7 +88,7 @@ BrowserID.PageHelpers = (function() { .promise().done(onComplete); } - function emailSent(onComplete) { + function emailSent(pollFuncName, onComplete) { origStoredEmail = getStoredEmail(); dom.setInner('#sentToEmail', origStoredEmail); @@ -96,7 +96,7 @@ BrowserID.PageHelpers = (function() { replaceInputsWithNotice(".emailsent"); - user.waitForUserValidation(origStoredEmail, function(status) { + user[pollFuncName](origStoredEmail, function(status) { userValidationComplete(status); }); onComplete && onComplete(); @@ -124,7 +124,7 @@ BrowserID.PageHelpers = (function() { function openPrimaryAuth(winchan, email, baseURL, callback) { if(!(email && baseURL)) { - throw "cannot verify with primary without an email address and URL" + throw "cannot verify with primary without an email address and URL"; } winchan.open({ diff --git a/resources/static/pages/js/signup.js b/resources/static/pages/js/signup.js index 49677c8e48721f6fb75f3e2a14726716569617be..1284ebf88418cac8dff4d94fbeeb705a0830f7c4 100644 --- a/resources/static/pages/js/signup.js +++ b/resources/static/pages/js/signup.js @@ -81,7 +81,7 @@ BrowserID.signUp = (function() { if(valid) { user.createSecondaryUser(this.emailToStage, pass, function(status) { if(status.success) { - pageHelpers.emailSent(oncomplete && oncomplete.curry(true)); + pageHelpers.emailSent("waitForUserValidation", oncomplete && oncomplete.curry(true)); } else { tooltip.showTooltip("#could_not_add"); diff --git a/resources/static/test/cases/pages/js/page_helpers.js b/resources/static/test/cases/pages/js/page_helpers.js index 40b8b22f17bd5c27681ec8c4fe1f586c438e4279..b389cbc506b61e717324c33c7a5f6812b16b2f20 100644 --- a/resources/static/test/cases/pages/js/page_helpers.js +++ b/resources/static/test/cases/pages/js/page_helpers.js @@ -99,7 +99,7 @@ // below. xhr.useResult("complete"); - pageHelpers.emailSent(function() { + pageHelpers.emailSent("waitForUserValidation", function() { equal($("#sentToEmail").html(), "registered@testuser.com", "correct email is set"); equal($(".emailsent").is(":visible"), true, "emailsent is visible"); equal($(".forminputs").is(":visible"), false, "inputs are hidden"); @@ -135,7 +135,7 @@ asyncTest("cancelEmailSent restores the stored email, inputs are shown again", function() { pageHelpers.setStoredEmail("registered@testuser.com"); xhr.useResult("complete"); - pageHelpers.emailSent(function() { + pageHelpers.emailSent("waitForUserValidation", function() { pageHelpers.cancelEmailSent(function() { var email = pageHelpers.getStoredEmail(); equal(email, "registered@testuser.com", "stored email is reset on cancel");