Skip to content
Permalink
Browse files

Added subscription confirmation email

  • Loading branch information...
davidmerfield committed Mar 12, 2019
1 parent a0bb5f7 commit a38771e52105eb8280cd38be7b9a01eac00aea38
Showing with 42 additions and 10 deletions.
  1. +38 −10 app/brochure/routes/news.js
  2. +1 −0 app/helper/email/index.js
  3. +3 −0 app/helper/email/user/SUBSCRIBE_CONFIRMATION.txt
@@ -12,32 +12,60 @@ news.get("/", loadDone, loadToDo, function(req, res) {
res.render("news");
});


news.get("/archive", loadDone, loadToDo, function(req, res) {
res.locals.title = "Blot / News";
res.render("news/archive");
});

news.post('/sign-up', parse, function(req, res){
console.log(req.body);
news.get("/sign-up", function(req ,res){
res.render("news/sign-up");
});

news.post("/sign-up", parse, function(req, res) {
var err;

if (!req.body || !req.body.email) {
err = new Error();
err.code = "ENOENT";
}

var confirm = "https://blot.development/news/confirm";

helper.email.SUBSCRIBE_CONFIRMATION(
null,
{ email: req.body.email.trim().toLowerCase(), confirm: confirm },
function(err) {
if (err) {
err = new Error();
err.code = "EINVAL";
}

req.message("/news/sign-up");
}
);
});

function loadToDo(req, res, next) {
fs.readFile(__dirname + "/../../../todo.txt", "utf-8", function(err, todo) {
if (err) return next(err);
res.locals.todo = marked(todo);

var html = res.locals.todo;
var $ = require('cheerio').load(html);
var $ = require("cheerio").load(html);

$('ul').each(function(){
$("ul").each(function() {
var ul = $(this).html();
var p = $(this).prev().html();

$(this).prev().remove();
$(this).replaceWith("<details><summary>" + p + "</summary><ul>" + ul + "</ul></details>");
});
var p = $(this)
.prev()
.html();

$(this)
.prev()
.remove();
$(this).replaceWith(
"<details><summary>" + p + "</summary><ul>" + ul + "</ul></details>"
);
});

res.locals.todo = $.html();
return next();
@@ -45,6 +45,7 @@ var MESSAGES = [
"RESTART",
"REVOKED",
"SET_PASSWORD",
"SUBSCRIBE_CONFIRMATION",
"SYNC_DOWN",
"SYNC_EXCEPTION",
"UPCOMING_RENEWAL",
@@ -0,0 +1,3 @@
Do you want to subscribe?

[Confirm subscription]({{{confirm}}})

0 comments on commit a38771e

Please sign in to comment.
You can’t perform that action at this time.