From c0c52e05a09e69b9c58871a3316941a817308ba8 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Fri, 20 Jul 2012 10:12:35 +0100 Subject: [PATCH] Fix forgot password redirection to /signin * to page_helpers.emailSent, add a new input paramter - pollFuncName. The poll functions are unique for each type of email sent. --- resources/static/pages/js/forgot.js | 2 +- resources/static/pages/js/page_helpers.js | 8 ++++---- resources/static/pages/js/signup.js | 2 +- resources/static/test/cases/pages/js/page_helpers.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/static/pages/js/forgot.js b/resources/static/pages/js/forgot.js index 5d7c93853..4d59778a1 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 9ec528c6b..c43ed717f 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 49677c8e4..1284ebf88 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 40b8b22f1..b389cbc50 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"); -- GitLab