From 80d838317ba88df58275923b153e5fc605b04f47 Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@lothar.com> Date: Tue, 22 May 2012 17:32:45 -0700 Subject: [PATCH] Move requiredEmail validation from state.js to dialog.js . Tests fail. Since validation is done earlier, invalid addresses are reported as with renderError() instead of startAction("doError"). So the tests which watch for doError are now failing (the frontend tests named "resources/state: start with invalid requiredEmail - print error screen" and "resources/state: start with empty requiredEmail - prints error screen". I don't know how to make them watch for renderError() instead. One upside of this patch is that @stomlinson told me the three-argument to startAction("doError"..) in state.js was a bug, as it only accepts two real arguments. Removing it is even easier than fixing it. --- resources/static/dialog/controllers/dialog.js | 6 +++++- resources/static/dialog/resources/state.js | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/static/dialog/controllers/dialog.js b/resources/static/dialog/controllers/dialog.js index 8517051de..8fbc31ce6 100644 --- a/resources/static/dialog/controllers/dialog.js +++ b/resources/static/dialog/controllers/dialog.js @@ -132,7 +132,11 @@ BrowserID.Modules.Dialog = (function() { // verify params try { - params.requiredEmail = paramsFromRP.requiredEmail; + if (typeof(paramsFromRP.requiredEmail) !== "undefined") { + if (!bid.verifyEmail(paramsFromRP.requiredEmail)) + throw "invalid requiredEmail: ("+paramsFromRP.requiredEmail+")"; + params.requiredEmail = paramsFromRP.requiredEmail; + } if (paramsFromRP.tosURL && paramsFromRP.privacyURL) { params.tosURL = fixupURL(origin_url, paramsFromRP.tosURL); params.privacyURL = fixupURL(origin_url, paramsFromRP.privacyURL); diff --git a/resources/static/dialog/resources/state.js b/resources/static/dialog/resources/state.js index 288dd0e08..6ef339ce5 100644 --- a/resources/static/dialog/resources/state.js +++ b/resources/static/dialog/resources/state.js @@ -46,11 +46,7 @@ BrowserID.State = (function() { self.tosURL = info.tosURL; requiredEmail = info.requiredEmail; - if ((typeof(requiredEmail) !== "undefined") && (!bid.verifyEmail(requiredEmail))) { - // Invalid format - startAction("doError", "invalid_required_email", {email: requiredEmail}); - } - else if (info.email && info.type === "primary") { + if (info.email && info.type === "primary") { primaryVerificationInfo = info; redirectToState("primary_user", info); } -- GitLab