diff --git a/authority/static/dialog/index.html b/authority/static/dialog/index.html index 669f4934c4430fa7e29aa55e9cba49d68b28a456..4cf619d1596e73148d5e93f37350fad8ac5e8d8a 100644 --- a/authority/static/dialog/index.html +++ b/authority/static/dialog/index.html @@ -63,9 +63,20 @@ <div id="confirmed_email_dialog" class="dialog"> <div class="title"> Confirm Your Email </div> <div class="content"> - <div class="summary">Welcome, <span class="email good"></span>. You will receive a <strong>confirmation email</strong> in a few moments. To activate your Firefox ID, please <strong>visit the link</strong> included in the email.</div> + <div class="summary">Welcome, <span class="email good"></span>. You will receive a <strong>confirmation email</strong> in a few moments. To prove that this is your email address, please <strong>visit the link</strong> included in the email.</div> <div class="attention_awesome "> - Your email has been confirmed and your Firefox ID created! </span> + Your email has been confirmed! </span> + </div> + </div> +</div> +<div id="add_email_dialog" class="dialog"> + <div class="title"> Add a new email address </div> + <div class="content"> + <div class="summary">Setting up a up a new email address is easy, tell us what it is and we'll get started:</div> + <div class="input"> + <div class="label"> Email </div> + <div class="input"> <input type="text"></input></div> + <div class="note"></div> </div> </div> </div> @@ -78,6 +89,7 @@ </div> <div class="actions"> <div class="action"><a href="#">Add a new email address</a></div> + <div class="action"><a href="#">This is not me.</a></div> </div> </div> <div id="error_dialog" class="dialog"> diff --git a/authority/static/dialog/main.js b/authority/static/dialog/main.js index d09bef798328de76cfe62ae41f8dbfd82557cce1..c7f9cdd1eb330af60e940eab280f47a8fb60dfda 100644 --- a/authority/static/dialog/main.js +++ b/authority/static/dialog/main.js @@ -25,14 +25,22 @@ onsuccess(assertion); }).text("Sign In").removeClass("disabled"); - $("#default_dialog div.actions div.action a").unbind('click').click(function() { - onerror("notImplemented"); + $("#sign_in_dialog div.actions div.action:first a").unbind('click').click(function() { + runAddNewAddressDialog(onsuccess, onerror); + }); + + $("#sign_in_dialog div.actions div.action:eq(1) a").unbind('click').click(function() { + // not your email addresses? we'll just purge local storage and click you over + // to the login page. + window.localStorage.emails = JSON.stringify({}); + runAuthenticateDialog(undefined, onsuccess, onerror); }); // now populate the selection list with all available emails // we assume there are identities available, because without them var emails = JSON.parse(window.localStorage.emails); var first = true; + $("form#identities").empty(); for (var k in emails) { var id = $("<div />") .append($("<input />").attr('type', 'radio').attr('name', 'identity').attr('checked', first)) @@ -153,7 +161,7 @@ runConfirmedEmailDialog(email, onsuccess, onerror); } else if (status === 'pending') { // try again, what else can we do? - pollTimeout = setupRegCheck(); + pollTimeout = setupRegCheck(); } else { runErrorDialog( "serverError", @@ -238,6 +246,59 @@ $("#waiting_dialog").fadeIn(500); } + function runAddNewAddressDialog(onsuccess, onerror) { + $(".dialog").hide(); + + $("#back").show().unbind('click').click(function() { + runSignInDialog(onsuccess, onerror); + }); + $("#cancel").show().unbind('click').click(function() { + onerror("canceled"); + }); + $("#submit").show().unbind('click').click(function() { + // ignore the click if we're disabled + if ($(this).hasClass('disabled')) return true; + + // now we need to actually try to stage the creation of this account. + var email = $("#create_dialog input:eq(0)").val(); + var keypair = CryptoStubs.genKeyPair(); + + // kick the user to waiting/status page while we talk to the server. + runWaitingDialog( + "One Moment Please...", + "We're adding this email to your account, this should only take a couple seconds.", + onsuccess, + onerror + ); + + $.ajax({ + url: '/wsapi/add_email?email=' + encodeURIComponent(email) + '&pubkey=' + encodeURIComponent(keypair.pub), + success: function() { + // email successfully staged, now wait for email confirmation + runConfirmEmailDialog(email, keypair, onsuccess, onerror); + }, + error: function() { + runErrorDialog( + "serverError", + "Error Creating Account!", + "There was a technical problem while trying to add this email to your account. Yucky.", + onsuccess, onerror); + } + }); + }).text("Add").addClass('disabled'); + + $("#add_email_dialog input").unbind('keyup').bind('keyup', function() { + var email = $("#add_email_dialog input:eq(0)").val(); + if (email.length > 0) { + $("#submit").removeClass('disabled'); + } else { + $("#submit").addClass('disabled'); + } + }); + + $("#add_email_dialog").fadeIn(500); + } + function runCreateDialog(onsuccess, onerror) { $(".dialog").hide(); diff --git a/authority/static/dialog/style.css b/authority/static/dialog/style.css index 524f3cbf8f055bc622901baf74fbca2200b4de1b..1c6ff0d44e82f621da611bf4ab8ccd26570d0ecf 100644 --- a/authority/static/dialog/style.css +++ b/authority/static/dialog/style.css @@ -78,6 +78,7 @@ span.sitename, span.email { div.actions > div.action { float: left; + margin-right: 1em; } div.actions > div.action a {