From 292f2ebf95314c17f690ff79638d1d2c76a84327 Mon Sep 17 00:00:00 2001 From: joates Date: Sat, 20 Sep 2014 02:21:47 +0100 Subject: [PATCH] v0.3.0-rc1 --- .gitignore | 2 +- config.json | 13 +++++++++++++ package.json | 2 +- server.js | 23 +++++++++++------------ 4 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 config.json diff --git a/.gitignore b/.gitignore index 47472fc..f4e3dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ pids logs results -npm-debug.log node_modules html/assets/js/email* +/config.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..5f8ced6 --- /dev/null +++ b/config.json @@ -0,0 +1,13 @@ +{ + "db": { + "path": "" + }, + + "email": { + "from" : "no-reply@squatconf.eu" + , "subject" : "Hello, everyone is welcome at SquatConf.." + , "bodyText": "Please verify that you wish to signup by following this link\n%link%\nYou can ignore this message if you DID NOT request to signup at our website\nhttp://squatconf.eu\n\nThe next event is in Paris, we hope to see you there !!\n\nKind regards from the team,\nSquatConf Paris 2014" + + } +} + diff --git a/package.json b/package.json index 2d34516..aee6ee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squatconf-web", - "version": "0.2.0", + "version": "0.3.0", "description": "website for the squatConf conference", "main": "server.js", "scripts": { diff --git a/server.js b/server.js index 0336b1e..b20f6dd 100644 --- a/server.js +++ b/server.js @@ -3,10 +3,11 @@ var nodemailer = require('nodemailer') , transporter = nodemailer.createTransport() , server = require('http').createServer(handler) + , email = require('./config.json').email + , rn = require('./src/rng') , fs = require('fs') , re = new RegExp('\.js$', 'i') , port = process.env.PORT || /*80*/ 8000 - , rn = require('./src/rng') function handler(req, res) { @@ -31,20 +32,18 @@ function handler(req, res) { /* var to_addr = params.query.email // @NOTE: - // Q: do we trust the user input ? - // A: FUCK NO !! + // Q: do we trust the user input ? + // A: FUCK NO !! + , url = 'http://squatconf.eu/confirm' + , link = url +'?email='+ to_addr +'&token='+ rn() +'\n\n' var opts = { - from: 'news-mailer@squatconf.eu', - to: to_addr, - subject: "Hello, everyone is welcome at SquatConf..", - text: 'Please verify that you wish to signup by following this link\n' - + 'http://squatconf.eu/confirm?email='+ to_addr +'&token='+ rn() '\n\n' - + 'You can ignore this message if you DID NOT request to signup at our website\n' - + 'http://squatconf.eu\n\n' - + 'next event is in Paris, we hope to see you there !!\n' - + 'kind regards from the team,\nSquatConf Paris 2014' + from : email.from + , to : to_addr + , subject: email.subject + , text : email.bodyText.replace(/\%link\%/, link) } + transporter.sendMail(opts, function(err, data) { if (err) return console.error('email problem !', err) console.log('email sent', data)