From a63e9c4194aba45710a2aa545072df68981cbb07 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Wed, 1 Feb 2012 19:13:14 +0000 Subject: [PATCH] Fixing the complete registration flow when the browser the user completes registration is different from the one they started at. * in check_registration.js, the "auth" message has been changed to "authenticate" * in user.js, when the registration poll completes, set the "known" field of the address in the addressInfo cache to "true" closes #1026, closes #973 --- .../static/dialog/controllers/check_registration.js | 2 +- resources/static/shared/user.js | 13 +++++++++++++ .../test/cases/controllers/check_registration.js | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/resources/static/dialog/controllers/check_registration.js b/resources/static/dialog/controllers/check_registration.js index 04a9711b6..05ed70777 100644 --- a/resources/static/dialog/controllers/check_registration.js +++ b/resources/static/dialog/controllers/check_registration.js @@ -38,7 +38,7 @@ BrowserID.Modules.CheckRegistration = (function() { }); } else if (status === "mustAuth") { - self.close("auth", { email: self.email }); + self.close("authenticate", { email: self.email }); oncomplete && oncomplete(); } }, self.getErrorDialog(errors.registration, oncomplete)); diff --git a/resources/static/shared/user.js b/resources/static/shared/user.js index e25e27d8a..d1994d335 100644 --- a/resources/static/shared/user.js +++ b/resources/static/shared/user.js @@ -112,6 +112,19 @@ BrowserID.User = (function() { // ensure that the stagedOnBehalfOf is cleared so there is no stale // data. storage.setStagedOnBehalfOf(""); + + // To avoid too many address_info requests, returns from each + // address_info request are cached. If the user is doing + // a registrationPoll, it means the user was registering the address + // and the registration has completed. Because the status is + // "complete" or "known", we know that the address is known, so we + // toggle the field to be up to date. If the known field remains + // false, then the user is redirected back to the authentication + // page and the system thinks the address must be verified again. + if(addressCache[email]) { + addressCache[email].known = true; + } + if (onSuccess) { onSuccess(status); } diff --git a/resources/static/test/cases/controllers/check_registration.js b/resources/static/test/cases/controllers/check_registration.js index c852f17d7..d24c8efc9 100644 --- a/resources/static/test/cases/controllers/check_registration.js +++ b/resources/static/test/cases/controllers/check_registration.js @@ -50,7 +50,7 @@ asyncTest("user validation with mustAuth result", function() { xhr.useResult("mustAuth"); - testVerifiedUserEvent("auth", "User Must Auth"); + testVerifiedUserEvent("authenticate", "User Must Auth"); }); asyncTest("user validation with pending->complete result ~3 seconds", function() { -- GitLab