Merge branch 'feature/mailGun' into develop

pull/15/head
Jérôme Loï 10 years ago
commit d6898721a9

1
.gitignore vendored

@ -17,4 +17,5 @@ results
node_modules
html/assets/js/email*
/config.json
config.js

@ -1,3 +1,7 @@
# SquatConf website.
```cp config-sample.js config.js```
edit congif with the mailgun api key
```npm i && npm start```

@ -6,11 +6,12 @@ module.exports = require('rc')(name, {
db_opts: { valueEncoding: 'json' }
, db_path: join(cwd, 'db', name)
, port: 8000
, host: "http://test.squatconf.eu"
, host: 'http://test.squatconf.eu'
, mailjetKey: 'key-...'
, 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"
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'
}
})

@ -146,5 +146,15 @@
</div>
<script src="assets/js/email.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-8478831-9', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>

@ -74,4 +74,14 @@
</footer> -->
</body>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-8478831-9', 'auto');
ga('send', 'pageview');
</script>
</html>

@ -28,7 +28,7 @@
"ecstatic": "^0.5.4",
"level": "^0.18.0",
"load-svg": "^1.0.0",
"nodemailer": "^1.3.0",
"mailgun": "^0.5.0",
"rc": "^0.5.1",
"stack": "^0.1.0",
"tiny-route": "^2.1.1",

@ -18,6 +18,7 @@ if(!fs.existsSync(config.db_path)){
});
}
stack.errorHandler = function error(req, res, err) {
res.statusCode = 302
res.setHeader('Location', '/')

@ -10,9 +10,9 @@ process.nextTick(function() {
, status_msg = document.getElementById('status-msg')
, logoCont = document.getElementById('logoCont')
loadsvg('/assets/img/squatconf_baguette.svg', function (err, svg) {
logoCont.appendChild(svg);
});
loadsvg('/assets/img/squatconf_baguette.svg', function (err, svg) {
logoCont.appendChild(svg);
});
for (var n = 0, l = form.childNodes[1].childNodes.length; n < l; n++) {
var el = form.childNodes[1].childNodes[n]

@ -2,6 +2,11 @@ var sanitize = require('xss-escape')
, rn = require('./rng')
, ip = require('./ip-trace')
, config = require('../config')
, Mailgun = require('mailgun').Mailgun
, mg = new Mailgun(config.mailjetKey);
module.exports = function(db) {
return function (req, res, next) {
@ -33,29 +38,34 @@ module.exports = function(db) {
if (err) return error(err)
// db write OK..
var nodemailer = require('nodemailer')
, transporter = nodemailer.createTransport()
, url = config.host +'/confirm'
var url = config.host +'/confirm'
, qstr = '?email='+ email +'&token='+ obj.token
, link = url + qstr +'\n\n'
var opts = {
, opts = {
from : config.email.from
, to : email
, subject: config.email.subject
, text : config.email.bodyText.replace(/\%link\%/, link)
}
transporter.sendMail(opts, function(err, data) {
if (err) return error(err)
mg.sendText(
opts.from
, email
, opts.subject
, opts.text
, {}
, function(err) {
if (err) console.log('Guru meditation: ' + err);
else{
res.statusCode = 302
res.setHeader('Location', '/')
console.log('email sent..', opts)}
return res.end()
});
// validation email sent
console.log('email sent..', opts)
res.statusCode = 302
res.setHeader('Location', '/')
return res.end()
})
})
} else {

Loading…
Cancel
Save