diff --git a/lib/static_resources.js b/lib/static_resources.js index d86bfd740f699c1873d26f50b092a0b80ca5fac3..3e0cf15d6f00a382af7dcad03a94d47d8fcbdf09 100644 --- a/lib/static_resources.js +++ b/lib/static_resources.js @@ -22,6 +22,7 @@ var common_js = [ '/lib/bidbundle.js', '/lib/ejs.js', '/lib/micrajax.js', + '/lib/urlparse.js', '/shared/javascript-extensions.js', '/i18n/:locale/client.json', '/shared/gettext.js', @@ -75,8 +76,6 @@ var dialog_min_js = '/production/:locale/dialog.js'; var dialog_js = und.flatten([ common_js, [ - '/lib/urlparse.js', - '/shared/command.js', '/shared/history.js', '/shared/state_machine.js', diff --git a/resources/static/css/style.css b/resources/static/css/style.css index 4cecf7645473b802c065ad18a1a9f52e81cf91b8..35bfa524ab66efd353488ddd596061022bb3fc77 100644 --- a/resources/static/css/style.css +++ b/resources/static/css/style.css @@ -557,12 +557,16 @@ button.delete:active { } #congrats .siteinfo { - margin-top: 10px; + margin-top: 10px; } #congrats .website { - display: block; - text-align: center; + display: block; + text-align: center; +} + +#redirection { + text-align: center; } diff --git a/resources/static/pages/verify_secondary_address.js b/resources/static/pages/verify_secondary_address.js index 47ce8d191a3679971729c5a5988580d69c763e96..df4561ec37b6707e3401afafd4f7c07225ba283a 100644 --- a/resources/static/pages/verify_secondary_address.js +++ b/resources/static/pages/verify_secondary_address.js @@ -9,6 +9,7 @@ BrowserID.verifySecondaryAddress = (function() { var ANIMATION_TIME=250, bid = BrowserID, user = bid.User, + storage = bid.Storage, errors = bid.Errors, pageHelpers = bid.PageHelpers, dom = bid.DOM, @@ -22,9 +23,11 @@ BrowserID.verifySecondaryAddress = (function() { mustAuth, verifyFunction, doc = document, - REDIRECT_TIMEOUT = 5000, + REDIRECT_SECONDS = 5, + secondsRemaining = REDIRECT_SECONDS, + email, redirectTo, - redirectTimeout; // set in config if available, use REDIRECT_TIMEOUT otw. + redirectTimeout; // set in config if available, use REDIRECT_SECONDS otw. function showError(el, oncomplete) { dom.hide(".hint,#signUpForm"); @@ -36,10 +39,20 @@ BrowserID.verifySecondaryAddress = (function() { if (info.returnTo) { dom.setInner(".website", info.returnTo); + updateRedirectTimeout(); dom.show(".siteinfo"); } } + function updateRedirectTimeout() { + if (secondsRemaining > 0) { + dom.setInner("#redirectTimeout", secondsRemaining); + + secondsRemaining--; + setTimeout(updateRedirectTimeout, 1000); + } + } + function submit(oncomplete) { var pass = dom.getInner("#password") || undefined, vpass = dom.getInner("#vpassword") || undefined, @@ -57,6 +70,14 @@ BrowserID.verifySecondaryAddress = (function() { pageHelpers.replaceFormWithNotice(selector, function() { if (redirectTo && verified) { + + // set the loggedIn status for the site. This allows us to get + // a silent assertion without relying on the dialog to set the + // loggedIn status for the domain. This is useful when the user + // closes the dialog OR if redirection happens before the dialog + // has had a chance to finish its business. + storage.setLoggedIn(URLParse(redirectTo).originOnly(), email); + setTimeout(function() { doc.location.href = redirectTo; complete(oncomplete, verified); @@ -85,6 +106,7 @@ BrowserID.verifySecondaryAddress = (function() { user.tokenInfo(token, function(info) { if (info) { redirectTo = info.returnTo; + email = info.email; showRegistrationInfo(info); needsPassword = info.needs_password; @@ -126,7 +148,7 @@ BrowserID.verifySecondaryAddress = (function() { redirectTimeout = options.redirectTimeout; if (typeof redirectTimeout === "undefined") { - redirectTimeout = REDIRECT_TIMEOUT; + redirectTimeout = REDIRECT_SECONDS * 1000; } startVerification(options.ready); diff --git a/resources/static/test/cases/pages/verify_secondary_address.js b/resources/static/test/cases/pages/verify_secondary_address.js index 99d2917af1a4c93aa1429069c449ae532f30d055..0d74afe90af7dc39c853bc3f8860a11adfbac517 100644 --- a/resources/static/test/cases/pages/verify_secondary_address.js +++ b/resources/static/test/cases/pages/verify_secondary_address.js @@ -71,14 +71,16 @@ }); asyncTest("no password: start with good token and site", function() { - storage.setReturnTo("browserid.org"); + var returnTo = "https://test.domain/path"; + storage.setReturnTo(returnTo); createController(config, function() { testEmail(); ok($(".siteinfo").is(":visible"), "siteinfo is visible when we say what it is"); - equal($(".website:nth(0)").text(), "browserid.org", "origin is updated"); + equal($(".website:nth(0)").text(), returnTo, "website is updated"); testHasClass("body", "complete"); - equal(doc.location.href, "browserid.org", "redirection occurred to correct URL"); + equal(doc.location.href, returnTo, "redirection occurred to correct URL"); + equal(storage.getLoggedIn("https://test.domain"), "testuser@testuser.com", "logged in status set"); start(); }); }); diff --git a/resources/views/add_email_address.ejs b/resources/views/add_email_address.ejs index 4a05fa34e2f7beb58679339b65aa1408976ea22f..9a4128aeee67fac5702ae45de569cd952d41fe4a 100644 --- a/resources/views/add_email_address.ejs +++ b/resources/views/add_email_address.ejs @@ -60,11 +60,15 @@ <div id="congrats"> <p> - <%- gettext('<strong class="email">Your address</strong> has been verified!') %> + <%- gettext('<strong class="email">Your address</strong> has been verified!') %> + </p> + + <p class="siteinfo"> + <%- format(gettext('Your new address is set up and ready to go. You will be redirected to %s'), ["<strong class='website'></strong>"]) %> + </p> - <p class="siteinfo"> - <%= gettext('Your new address is set up and ready to go. You will be redirected to') %> <strong class="website"></strong> - </p> + <p id="redirection" class="siteinfo"> + <%- format(gettext("Redirecting in %s seconds"), ["<span id='redirectTimeout'></span>" ]) %> </p> </div> </div> diff --git a/resources/views/verify_email_address.ejs b/resources/views/verify_email_address.ejs index 5e5ffa4ca9ab865415a9ae2875428093d26c3856..d033b9417e2b39158d875138bb6ec24aca1a0286 100644 --- a/resources/views/verify_email_address.ejs +++ b/resources/views/verify_email_address.ejs @@ -62,7 +62,11 @@ </p> <p class="siteinfo"> - <%= gettext('Your new address is set up and ready to go. You will be redirected to') %> <strong class="website"></strong> + <%- format(gettext('Your new address is set up and ready to go. You will be redirected to %s'), ["<strong class='website'></strong>"]) %> + </p> + + <p id="redirection" class="siteinfo"> + <%- format(gettext("Redirecting in %s seconds"), ["<span id='redirectTimeout'></span>" ]) %> </p> </div>