forked from Squatconf/Website
commit
3bbae1bc74
@ -1,7 +1,3 @@
|
||||
# SquatConf website.
|
||||
|
||||
```cp config-sample.js config.js```
|
||||
|
||||
edit congif with the mailgun api key
|
||||
|
||||
```npm i && npm start```
|
||||
```npm install && npm start```
|
||||
|
@ -1,17 +0,0 @@
|
||||
var join = require('path').join
|
||||
, name = 'squatconf'
|
||||
, cwd = process.cwd()
|
||||
|
||||
module.exports = require('rc')(name, {
|
||||
db_opts: { valueEncoding: 'json' }
|
||||
, db_path: join(cwd, 'db', name)
|
||||
, port: 8000
|
||||
, 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'
|
||||
}
|
||||
})
|
||||
|
@ -1,85 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>SquatConf.386</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Squatconf webSite">
|
||||
|
||||
<link href="assets/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="assets/css/squatconf.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="span3 leftCol">
|
||||
<ul class="nav nav-list">
|
||||
<li><a href="/"><i class="icon-chevron-right"></i> SquatConf</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- content -->
|
||||
<div class="span9">
|
||||
<div class="page-header">
|
||||
<pre class="maxW"><small>
|
||||
.d8888b. 888 .d888
|
||||
d88P Y88b 888 d88P"
|
||||
Y88b. 888 888
|
||||
"Y888b. .d88888888 888 8888b. 888888 .d8888b .d88b. 88888b. 888888
|
||||
"Y88b.d88" 888888 888 "88b888 d88P" d88""88b888 "88b888
|
||||
"888888 888888 888.d888888888 888 888 888888 888888
|
||||
Y88b d88PY88b 888Y88b 888888 888Y88b. Y88b. Y88..88P888 888888
|
||||
"Y8888P" "Y88888 "Y88888"Y888888 "Y888 "Y8888P "Y88P" 888 888888
|
||||
888
|
||||
888
|
||||
888
|
||||
<br></small></pre>
|
||||
<pre class="dskW">
|
||||
____ _ ____ __
|
||||
/ ___| __ _ _ _ __ _| |_ / ___|___ _ __ / _|
|
||||
\___ \ / _` | | | |/ _` | __| | / _ \| '_ \| |_
|
||||
___) | (_| | |_| | (_| | |_| |__| (_) | | | | _|
|
||||
|____/ \__, |\__,_|\__,_|\__|\____\___/|_| |_|_|
|
||||
|_|
|
||||
<br></pre>
|
||||
<pre class="tblW">
|
||||
|
||||
(~ _ _ _|_/~` _ _ |`
|
||||
_)(_||_|(_| | \_,(_)| |~|~
|
||||
|/
|
||||
<br></pre>
|
||||
</div>
|
||||
<div>
|
||||
<h2 id="email-verified" class="pull-left">You're verified</h2>
|
||||
<br /><br />
|
||||
<p>Thanks for completing our signup process</p>
|
||||
<br />
|
||||
<a href="/" class="btn">Go back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer
|
||||
================================================== -->
|
||||
<!-- <footer class="footer">
|
||||
<div class="container">
|
||||
some info, maybe ? ;)
|
||||
</div>
|
||||
|
||||
</footer> -->
|
||||
</body>
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
|
||||
ga('create','UA-8478831-9','auto');ga('send','pageview');
|
||||
</script>
|
||||
</html>
|
@ -1,56 +0,0 @@
|
||||
var ready = require('domready')
|
||||
, check_email = require('valid-email')
|
||||
, loadsvg = require('load-svg')
|
||||
|
||||
process.nextTick(function() {
|
||||
ready(function() {
|
||||
|
||||
var form = document.getElementById('signup-form')
|
||||
, input_email = ''
|
||||
, status_msg = document.getElementById('status-msg')
|
||||
, logoCont = document.getElementById('logoCont')
|
||||
|
||||
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]
|
||||
if (el.nodeName === 'INPUT' && el.name === 'email')
|
||||
input_email = el
|
||||
}
|
||||
|
||||
document
|
||||
.getElementById("signup-form")
|
||||
.addEventListener("click", function(e) {
|
||||
if (e.srcElement.nodeName === 'BUTTON') {
|
||||
if (input_email && input_email.value) {
|
||||
var is_valid = check_email(input_email.value)
|
||||
if (is_valid) {
|
||||
var progress = 0
|
||||
, timerID = null
|
||||
e.preventDefault()
|
||||
status_msg.className = 'info'
|
||||
status_msg.innerHTML = "Sending"
|
||||
timerID = setInterval(function() {
|
||||
if (++progress < 8) {
|
||||
status_msg.innerHTML += "."
|
||||
} else {
|
||||
clearInterval(timerID)
|
||||
form.submit()
|
||||
}
|
||||
}, 150)
|
||||
} else {
|
||||
e.preventDefault()
|
||||
input_email.value = ''
|
||||
status_msg.className = 'error'
|
||||
status_msg.innerHTML = "that doesn't look like an email address,"
|
||||
+ "<br />please try again..."
|
||||
setTimeout(function() { status_msg.innerHTML = ' ' }, 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,48 +0,0 @@
|
||||
var sanitize = require('xss-escape')
|
||||
, ip = require('./ip-trace')
|
||||
|
||||
module.exports = function(db) {
|
||||
return function (req, res, next) {
|
||||
req.resume()
|
||||
|
||||
function error(e) {
|
||||
console.error(e)
|
||||
return next(e || e.msg || 'ERROR')
|
||||
}
|
||||
|
||||
var params = require('url').parse(req.url, true)
|
||||
|
||||
if (params && params.query.email && params.query.token) {
|
||||
|
||||
var email = sanitize(params.query.email)
|
||||
, token = sanitize(params.query.token)
|
||||
|
||||
db.get(email, function(err, obj) {
|
||||
if (err) return error(err)
|
||||
|
||||
// db read OK..
|
||||
if (obj && ! obj.verified) {
|
||||
if (obj.token === token) {
|
||||
obj.verified = true
|
||||
obj.trace = obj.trace.concat(ip(req))
|
||||
|
||||
db.put(email, obj, function(err) {
|
||||
if (err) return error(err)
|
||||
|
||||
// db write OK..
|
||||
res.statusCode = 302
|
||||
res.setHeader('Location', '/verified.html')
|
||||
return res.end()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
error('email is already verified: '+ email)
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
error('invalid input: '+ JSON.stringify(params.query))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,81 +0,0 @@
|
||||
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) {
|
||||
req.resume()
|
||||
|
||||
function error(e) {
|
||||
console.error(e)
|
||||
return next(e || e.msg || 'ERROR')
|
||||
}
|
||||
|
||||
var params = require('url').parse(req.url, true)
|
||||
|
||||
if (params && params.query.email) {
|
||||
|
||||
var obj = {}
|
||||
, email = sanitize(params.query.email)
|
||||
|
||||
db.get(email, function(err, value) {
|
||||
if ((err && err.type == 'NotFoundError') || ! value.verified) {
|
||||
|
||||
console.log('got email:', params.query)
|
||||
|
||||
obj.token = rn()
|
||||
obj.verified = false
|
||||
obj.events = { paris: params.query.paris ? true : false }
|
||||
obj.trace = ip(req)
|
||||
|
||||
db.put(email, obj, function(err) {
|
||||
if (err) return error(err)
|
||||
|
||||
// db write OK..
|
||||
var url = config.host +'/confirm'
|
||||
, qstr = '?email='+ email +'&token='+ obj.token
|
||||
, link = url + qstr +'\n\n'
|
||||
, opts = {
|
||||
from : config.email.from
|
||||
, to : email
|
||||
, subject: config.email.subject
|
||||
, text : config.email.bodyText.replace(/\%link\%/, link)
|
||||
}
|
||||
|
||||
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()
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
} else {
|
||||
error('already verified: '+ email)
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
error('invalid input: '+ JSON.stringify(params.query))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
module.exports = function(req) {
|
||||
if (req.headers['x-forwarded-for']) {
|
||||
return req.headers['x-forwarded-for'].split(',')
|
||||
} else {
|
||||
return [ req.connection.remoteAddress ]
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
module.exports = function() {
|
||||
var crypto = require('crypto')
|
||||
|
||||
function rng_Base64(len) {
|
||||
return crypto.randomBytes(Math.ceil(len * 3 / 4))
|
||||
.toString('base64')
|
||||
.slice(0, len)
|
||||
.replace(/\+/g, '0')
|
||||
.replace(/\//g, '0')
|
||||
}
|
||||
|
||||
return [ rng_Base64(8)
|
||||
, rng_Base64(4)
|
||||
, rng_Base64(4)
|
||||
, rng_Base64(4)
|
||||
, rng_Base64(12)
|
||||
]
|
||||
.join('-')
|
||||
}
|
||||
|
Loading…
Reference in New Issue