diff --git a/README.md b/README.md index 1c24f1e61f4bba0130f473ca080a79ced7637b32..d3e599804e4ed870b101f9ce06708b94a4bd0c20 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ All of the servers here are based on node.js, and some number of 3rd party node * nodemailer (>= 0.1.18) * emavows (>= 0.5.8) * bcrypt (>= 0.2.3) +* ejs (>= 0.4.3) ## Getting started: diff --git a/browserid/app.js b/browserid/app.js index 26ea69ba16a6f6fae8af8cdf895da9f44ae0aa64..dff83159fbdadfba41658181af2e062a9be8c5bb 100644 --- a/browserid/app.js +++ b/browserid/app.js @@ -29,10 +29,23 @@ function internal_redirector(new_url) { } function router(app) { + app.set("views", __dirname + '/views'); + // simple redirects (internal for now) app.get('/sign_in', internal_redirector('/dialog/index.html')); app.get('/register_iframe', internal_redirector('/dialog/register_iframe.html')); - app.get('/privacy', internal_redirector('/privacy.html')); + + app.get('/', function(req,res) { + res.render('index.ejs', {title: 'A Better Way to Log In', fullpage: true}); + }); + + app.get('/users', function(req,res) { + res.render('users.ejs', {title: 'for Users', fullpage: false}); + }); + + app.get('/privacy', function(req, res) { + res.render('privacy.ejs', {title: 'Privacy and Terms of Service', fullpage: false}); + }); // register all the WSAPI handlers wsapi.setup(app); diff --git a/browserid/views/index.ejs b/browserid/views/index.ejs new file mode 100644 index 0000000000000000000000000000000000000000..fffcde351cf15f50f4a5fb7dd7ada537960a26d7 --- /dev/null +++ b/browserid/views/index.ejs @@ -0,0 +1,12 @@ + <div class="why"> + <img style="float: right;" src="i/people.png"> + <p>For <b>users</b>, BrowserID provides a <b>safer and easier</b> way to log in. <a href="/users">How it works.</a></p> + </div> + <div class="why"> + <img style="float: left;" src="i/developers.png"> + <p>For <b>developers</b>, BrowserID offers a world class login experience with only a couple lines of code. <a href="developers.html">Get Started.</a></p> + </div> + <div class="why"> + <img style="float: right;" src="i/id.png"> + <p>For <b>identity providers</b>, BrowserID lets your give your users an identity they can <b>use everywhere</b>. <a href="primaries.html">Dig Deeper.</a> </p> + </div> diff --git a/browserid/views/layout.ejs b/browserid/views/layout.ejs new file mode 100644 index 0000000000000000000000000000000000000000..16768db9c19b8c58f708eb4f74bceef839b6d457 --- /dev/null +++ b/browserid/views/layout.ejs @@ -0,0 +1,113 @@ +<!DOCTYPE html> +<html> +<head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8"> + <title><%- title %></title> + <link rel="stylesheet" href="/css/style.css" type="text/css"> +</head> +<body> +<div id="splash"> + <% if (fullpage) { %> + <div class="header"> + <div class="manage"><a id="manageLink" href="manage.html">manage my logins</a></div> + </div> + <div class="tophalf"> + <div class="title"><img src="i/browserid_logo.png"></div> + <div class="subtitle">A better way to log in.</div> + </div> + <% } else { %> + <div class="topquarter"> + <div> + <a href="/"><div class="title"><img src="i/browserid_logo_lil.png"></div></a> + <div class="subtitle"><%- title %></div> + </div> + </div> + <% } %> + <div class="bottomhalf"> + <%- body %> + </div> + <div class="footer"> + <div> + <div class="right"> + <p><img src="i/browserid_logo_sm.png"> is an <b>open source experiment</b> into improving identity and authentication on the web, by + <a href="https://mozillalabs.com">mozilla labs</a>.</p> + </div> + <div class="left"> + <p> <a href="https://github.com/mozilla/browserid">Source Code</a> <a href="https://wiki.mozilla.org/Identity/Verified_Email_Protocol">Specification</a> <a href="http://groups.google.com/group/mozilla-labs">Mailing list</a> <a href="/privacy">Privacy</a> </p> + <p class="copyright">Copyright © 2011 Mozilla. All rights reserved. </p> + </div> + </div> + </div> +</div> +</body> +<script src="dialog/jquery-min.js"></script> +<script src="dialog/underscore-min.js"></script> +<script> +function display_saved_ids() +{ + var emails = {}; + if (window.localStorage.emails) { + emails = JSON.parse(window.localStorage.emails); + } + + $('#cancellink').click(function() { + if (confirm('Are you sure you want to cancel your account?')) { + $.post("/wsapi/account_cancel", {}, function(result) { + window.localStorage.emails = null; + document.location="/"; + }); + } + }); + + $("#emailList").empty(); + _(emails).each(function(data, e) { + var block = $("<div>").addClass("emailblock"); + var label = $("<div>").addClass("email").text(e); + var meta = $("<div>").addClass("meta"); + + /* + var priv = $("<div class='keyblock'>").text(data.priv); + priv.hide(); + */ + + var pub = $("<div class='keyblock'>").text(data.pub); + pub.hide(); + var linkblock = $("<div>"); + var puba = $("<a>").text("[show public key]"); + // var priva = $("<a>").text("[show private key]"); + puba.click(function() {pub.show()}); + // priva.click(function() {priv.show()}); + linkblock.append(puba); + // linkblock.append(" / "); + // linkblock.append(priva); + + var deauth = $("<button>").text("Forget this Email"); + meta.append(deauth); + deauth.click(function() { + var t = JSON.parse(window.localStorage.emails); + delete t[e]; + window.localStorage.emails = JSON.stringify(t); + // remove email from server + $.post("/wsapi/remove_email", {"email" : e}, function(response) { + alert("response is : " +response); + display_saved_ids(); + }); + }); + + var d = new Date(data.created); + var datestamp = $("<div class='date'>").text("Logged in at " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + ", " + d.getMonth() + "/" + d.getDay() + "/" + d.getUTCFullYear()); + + meta.append(datestamp); + meta.append(linkblock); + + block.append(label); + block.append(meta); + // block.append(priv); + block.append(pub); + + $("#emailList").append(block); + }); +} +</script> + +</html> diff --git a/browserid/views/privacy.ejs b/browserid/views/privacy.ejs new file mode 100644 index 0000000000000000000000000000000000000000..d1ab9be82b30e2cbf7db58e66b4e565e59348edf --- /dev/null +++ b/browserid/views/privacy.ejs @@ -0,0 +1,8 @@ + <div class="why"> + <p> + Privacy Policy and Terms of Service + </p> + </div> + <div> + to be filled in soon + </div> diff --git a/browserid/views/users.ejs b/browserid/views/users.ejs new file mode 100644 index 0000000000000000000000000000000000000000..c533737ab1537be8307911201c31a90463d8e276 --- /dev/null +++ b/browserid/views/users.ejs @@ -0,0 +1,10 @@ + <div class="why"> + <p> + This page is dedicated to the <b>Users</b>. They matter <b>a + lot</b>. This page hasn't been written yet, but rather than + getting frustrated that the content doesn't exist, you should + go write it, + then <a href="https://github.com/mozilla/browserid/blob/master/browserid/static/users.html">contribute + it on github</a>. + </p> + </div> diff --git a/run.js b/run.js index 1f0a8a6a17c1d549a03939d717d568364491e5ce..ba23c8c899cc9f1180f9d7782f8aaecacb915a81 100755 --- a/run.js +++ b/run.js @@ -63,6 +63,7 @@ function substitutionMiddleware(req, resp, next) { var realWrite = resp.write; var realEnd = resp.end; var realWriteHead = resp.writeHead; + var realSend = resp.send; var buf = undefined; var enc = undefined; @@ -80,7 +81,7 @@ function substitutionMiddleware(req, resp, next) { } if (!contentType) contentType = resp.getHeader('content-type'); if (!contentType) contentType = "application/unknown"; - realWriteHead(sc, reason, hdrs); + realWriteHead.call(resp, sc, reason, hdrs); }; resp.write = function (chunk, encoding) { @@ -89,6 +90,11 @@ function substitutionMiddleware(req, resp, next) { enc = encoding; }; + resp.send = function(stuff) { + buf = stuff; + realSend.call(resp,stuff); + }; + resp.end = function() { if (!contentType) contentType = resp.getHeader('content-type'); if (contentType && (contentType === "application/javascript" || @@ -100,7 +106,9 @@ function substitutionMiddleware(req, resp, next) { if (l != buf.length) resp.setHeader('Content-Length', buf.length); } } - if (buf && buf.length) realWrite.call(resp, buf, enc); + if (buf && buf.length) { + realWrite.call(resp, buf, enc); + } realEnd.call(resp); }