diff --git a/authority/static/include.js b/authority/static/include.js index 1eb103e761a80367f0962b000d6c0999b207caca..1af611c5b0cb0b9a78f88f04c457278dddeaeb3c 100644 --- a/authority/static/include.js +++ b/authority/static/include.js @@ -565,7 +565,7 @@ if (!navigator.id.getVerifiedEmail || navigator.id._getVerifiedEmailIsShimmed) "menubar=0,location=0,resizable=0,scrollbars=0,status=0,dialog=1,width=600,height=400"); } - navigator.id.getVerifiedEmail = function(onsuccess, onerror) { + navigator.id.getVerifiedEmail = function(callback) { var w = _open_window(); // clean up a previous channel that never was reaped @@ -581,14 +581,15 @@ if (!navigator.id.getVerifiedEmail || navigator.id._getVerifiedEmailIsShimmed) chan.call({ method: "getVerifiedEmail", success: function(rv) { - if (onsuccess) { + if (callback) { // wrap the raw JWT with a handy dandy object that exposes everything in a readable form - onsuccess(JWTWrapper(rv)); + callback(JWTWrapper(rv)); } cleanup(); }, error: function(code, msg) { - if (onerror) onerror(code, msg); + // XXX: we don't make the code and msg available to the user. + if (callback) callback(null); cleanup(); } }); diff --git a/rp/index.html b/rp/index.html index bad10a34bb58c2577480d30b770ae47d74c7b1fe..38661544ceb44f59327c9d0c50fc0700952335a1 100644 --- a/rp/index.html +++ b/rp/index.html @@ -97,24 +97,26 @@ a:hover { border-bottom: 2px solid black ; } $(document).ready(function() { $("#partyStarter").click(function() { navigator.id.getVerifiedEmail(function(assertion) { - // Now we'll send this assertion over to the verification server for validation - $("#oAssertion").empty().html(dumpObject(assertion)); - - var url = "http://browserid.org/verify?assertion=" + window.encodeURIComponent(assertion) + - "&audience=" + window.encodeURIComponent("rp.eyedee.me"); - $("#oVerificationRequest").empty().text(url); - - $.ajax({ - url: url, - success: function(data, textStatus, jqXHR) { - $("#oVerificationResponse").empty().text(JSON.stringify(data, null, 4)); - }, - error: function(jqXHR, textStatus, errorThrown) { - $("#oVerificationResponse").empty().text(jqXHR.responseText); - } - }) - }, function(code, msg) { - alert("something very bad happened! ("+code+"): " + msg); + if (!assertion) { + alert("couldn't get the users email address!"); + } else { + // Now we'll send this assertion over to the verification server for validation + $("#oAssertion").empty().html(dumpObject(assertion)); + + var url = "http://browserid.org/verify?assertion=" + window.encodeURIComponent(assertion) + + "&audience=" + window.encodeURIComponent("rp.eyedee.me"); + $("#oVerificationRequest").empty().text(url); + + $.ajax({ + url: url, + success: function(data, textStatus, jqXHR) { + $("#oVerificationResponse").empty().text(JSON.stringify(data, null, 4)); + }, + error: function(jqXHR, textStatus, errorThrown) { + $("#oVerificationResponse").empty().text(jqXHR.responseText); + } + }) + } }); }); }); diff --git a/run.js b/run.js index 569ccd1fd5170641e1106e73d63a1aefeea1c136..18384d1c4a1a0ebc6abdba0b26b565228fcd803c 100644 --- a/run.js +++ b/run.js @@ -63,11 +63,13 @@ function createServer(obj) { resp.end = function() { var ct = resp.getHeader('content-type'); if (ct && (ct === "application/javascript" || ct.substr(4) === 'text')) { - var l = buf.length; - buf = subHostNames(buf); - if (l != buf.length) resp.setHeader('Content-Length', buf.length); + if (buf) { + var l = buf.length; + buf = subHostNames(buf); + if (l != buf.length) resp.setHeader('Content-Length', buf.length); + } } - if (buf && buf.length) realWrite.call(resp, buf, enc ? enc : "binary"); + if (buf && buf.length) realWrite.call(resp, buf, enc); realEnd.call(resp); }