MyFavoriteShow.org - A BrowserID example site
This is a simple site that demonstrates how BrowserID can be used to to accept verified emails from users for the purposes of signup to email lists or fan lists.
BrowserID is a distributed system that allows users to use their email address as login name and password. Go read more about how browserid works if you like.
This repository contains a sample that explores more fully a single use case of browserid, namely using it as a means to allow users to share verified email addresses with a site, so that sites easily implement a "join our mailing list" feature in a robust manner - letting BrowserID handle the problem of verifying that users actually own the email address that they enter.
MyFavoriteShow.org is a site dedicated to a fictional TV show "The Great Identity Race". Fans of the show can come to this site, read a bunch about it, and their favorite stars of the show. Additionally, users can choose to register or unregister for the show's email list. Registration leverages browserid to confirm that users only register email addresses that they actually own.
The web services api exported by the node.js server consists of the following:
/api/register- registers an email address to the show's mailing list.
/api/unregiser- unregisters an email address from the show's mailing list.
Further documentation of these calls is available in the source code.
We have to store the email list somewhere. mongodb is used
for this purpose and a very simple database abstraction layer exists
db.js. The details of interacting with the database aren't
important, but if you're curious have a look in db.js.
To run the example code locally:
- clone this repository
- install node (0.4.7+) and npm.
On stdout you'll see an ip address and port, like
127.0.0.1:59275. Open that
up in your web browser.
NOTE: You'll see warnings about how no database is configured. Don't worry about it. The code is designed to run with or without a configured database so that it's easier to play with. The only downside of running without a database is that your server won't remember anything. Oh well.
The code is designed to run on heroku's node.js hosting services, and
the only way this affects the implementation is via environment
variable naming choices and the presence of a
Procfile which tells
heroku how to start the server.
If you'd like to deploy this service to heroku yourself, all you'd have to do is:
- set up a heroku account (and run through their tutorial)
- add a free mongolab instance (for persistence):
heroku addons:add mongolab:starter
- set your app to bind to all available ips:
heroku config:add IP_ADDRESS=0.0.0.0
- set a random string to encrypt cookies:
heroku config:add SEKRET=<long random string>
- push the code up to heroku!
NOTE: While the sample is targeted at heroku, with minimal code modifications it should run under the hosting environment of your preference.
Concept + Design(kinda): https://myfavouritesandwich.org/