aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2015-01-03 12:03:59 -0800
committerAdam Soltys <[email protected]>2015-01-03 12:03:59 -0800
commit15ee6390c1831199da840d63c25edeacff1daebe (patch)
tree4ff6237285f135abe2ab50f5fb9c2b33860bb916 /src
parent0575689747b2868205ceb48ead622032ebe173fe (diff)
downloadcoinos-server-15ee6390c1831199da840d63c25edeacff1daebe.tar.gz
coinos-server-15ee6390c1831199da840d63c25edeacff1daebe.zip
Only send mail in production
Diffstat (limited to 'src')
-rw-r--r--src/routes/users.coffee52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/routes/users.coffee b/src/routes/users.coffee
index 838ef631..d3ecabaf 100644
--- a/src/routes/users.coffee
+++ b/src/routes/users.coffee
@@ -83,33 +83,34 @@ module.exports = (sessions) ->
)
)
- require('crypto').randomBytes(48, (ex, buf) ->
- token = buf.toString('base64').replace(/\//g,'').replace(/\+/g,'')
- db.set("token:#{token}", req.body.username)
- host = req.hostname
- host += ':3000' if host is 'localhost'
- url = "#{req.protocol}://#{host}/verify/#{token}"
+ if process.env.NODE_ENV is 'production'
+ require('crypto').randomBytes(48, (ex, buf) ->
+ token = buf.toString('base64').replace(/\//g,'').replace(/\+/g,'')
+ db.set("token:#{token}", req.body.username)
+ host = req.hostname
+ host += ':3000' if host is 'localhost'
+ url = "#{req.protocol}://#{host}/verify/#{token}"
- res.render('users/welcome',
- user: req.params.user,
- layout: 'mail',
- url: url,
- privkey: req.body.privkey,
- js: (-> global.js),
- css: (-> global.css),
- (err, html) ->
- sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password)
+ res.render('users/welcome',
+ user: req.params.user,
+ layout: 'mail',
+ url: url,
+ privkey: req.body.privkey,
+ js: (-> global.js),
+ css: (-> global.css),
+ (err, html) ->
+ sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password)
- email = new sendgrid.Email(
- to: req.body.email
- subject: 'Welcome to CoinOS'
- html: html
- )
+ email = new sendgrid.Email(
+ to: req.body.email
+ subject: 'Welcome to CoinOS'
+ html: html
+ )
- sendgrid.send(email)
+ sendgrid.send(email)
+ )
)
- )
)
edit: (req, res) ->
@@ -148,7 +149,10 @@ module.exports = (sessions) ->
res.redirect("/#{req.params.user}")
)
- if req.body.privkey? and req.body.privkey != '' and req.body.email != ''
+ if process.env.NODE_ENV is 'production' and
+ req.body.privkey? and
+ req.body.privkey != '' and
+ req.body.email != ''
res.render('users/key',
user: req.params.user,
layout: 'mail',