From ac3bfe6f1daa1df6ddd1520271ea01c3f5bf67c1 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Tue, 14 Jun 2011 23:07:18 -0600 Subject: [PATCH] Finish sending of confirmation emails: closes #3. --- README.md | 1 + authority/server/email.js | 18 ++++++++++++++++-- authority/server/prove_template.txt | 13 +++++++++++++ authority/static/dialog/index.html | 2 +- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 authority/server/prove_template.txt diff --git a/README.md b/README.md index 98d2494fd..86a4a8dc6 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ All of the servers here are based on node.js, and some number of 3rd party node * sqlite (>= 1.0.3) * mustache (>= 0.3.1) * cookie-sessions (>= 0.0.2) +* nodemailer (>= 0.1.18) ## Getting started: diff --git a/authority/server/email.js b/authority/server/email.js index 0266c9bce..59a01aa96 100644 --- a/authority/server/email.js +++ b/authority/server/email.js @@ -1,6 +1,20 @@ -const db = require('./db'); +const db = require('./db'), + emailer = require('nodemailer'), + fs = require('fs'), + path = require('path'), +mustache = require('mustache'); + +const template = fs.readFileSync(path.join(__dirname, "prove_template.txt")).toString(); exports.sendVerificationEmail = function(email, secret) { var url = "https://browserid.org/prove.html?token=" + secret; - console.log("sending a verification email with url: " + url); + + emailer.send_mail({ + sender: "noreply@browserid.org", + to: email, + subject : "BrowserID: confirm email address - " + email, + body: mustache.to_html(template, { email: email, link: url }) + }, function(err, success){ + if(!success) console.log("error sending email: ", err); + }); }; diff --git a/authority/server/prove_template.txt b/authority/server/prove_template.txt new file mode 100644 index 000000000..92424a3af --- /dev/null +++ b/authority/server/prove_template.txt @@ -0,0 +1,13 @@ +Hello {{email}}, + +This message is being sent to you because someone is trying to log +into a site using this email address. If you are presently logging +into a website using BrowserID, then click the link below to complete +your login: + +{{link}} + +If you are NOT trying to log into a website, just delete this email. + +Sincerely, +BrowserID (A better way to login) diff --git a/authority/static/dialog/index.html b/authority/static/dialog/index.html index 50e36b5da..c0fb00329 100644 --- a/authority/static/dialog/index.html +++ b/authority/static/dialog/index.html @@ -53,7 +53,7 @@ <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 BrowserID, please <strong>visit the link</strong> included in the email.</div> <div class="attention"> - Waiting for email confirmation... <span class="bad"> THIS ISN'T REAL! JUST WAIT 5 SECONDS!</span> + Waiting for email confirmation... </div> <div class="actions"> <div class="action"> No email yet? <a href="#">Resend it!</a></div> -- GitLab