diff options
| author | Adam Soltys <[email protected]> | 2015-01-03 12:03:59 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2015-01-03 12:03:59 -0800 |
| commit | 15ee6390c1831199da840d63c25edeacff1daebe (patch) | |
| tree | 4ff6237285f135abe2ab50f5fb9c2b33860bb916 /routes | |
| parent | 0575689747b2868205ceb48ead622032ebe173fe (diff) | |
| download | coinos-server-15ee6390c1831199da840d63c25edeacff1daebe.tar.gz coinos-server-15ee6390c1831199da840d63c25edeacff1daebe.zip | |
Only send mail in production
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/users.js | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/routes/users.js b/routes/users.js index 46a8f8f8..c5e0f0ee 100644 --- a/routes/users.js +++ b/routes/users.js @@ -113,38 +113,40 @@ return sessions.create(req, res); }); }); - return require('crypto').randomBytes(48, function(ex, buf) { - var host, token, url; - token = buf.toString('base64').replace(/\//g, '').replace(/\+/g, ''); - db.set("token:" + token, req.body.username); - host = req.hostname; - if (host === 'localhost') { - host += ':3000'; - } - url = "" + req.protocol + "://" + host + "/verify/" + token; - return res.render('users/welcome', { - user: req.params.user, - layout: 'mail', - url: url, - privkey: req.body.privkey, - js: (function() { - return global.js; - }), - css: (function() { - return global.css; - }) - }, function(err, html) { - var email, sendgrid; - sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password); - email = new sendgrid.Email({ - to: req.body.email, - from: '[email protected]', - subject: 'Welcome to CoinOS', - html: html + if (process.env.NODE_ENV === 'production') { + return require('crypto').randomBytes(48, function(ex, buf) { + var host, token, url; + token = buf.toString('base64').replace(/\//g, '').replace(/\+/g, ''); + db.set("token:" + token, req.body.username); + host = req.hostname; + if (host === 'localhost') { + host += ':3000'; + } + url = "" + req.protocol + "://" + host + "/verify/" + token; + return res.render('users/welcome', { + user: req.params.user, + layout: 'mail', + url: url, + privkey: req.body.privkey, + js: (function() { + return global.js; + }), + css: (function() { + return global.css; + }) + }, function(err, html) { + var email, sendgrid; + sendgrid = require('sendgrid')(config.sendgrid_user, config.sendgrid_password); + email = new sendgrid.Email({ + to: req.body.email, + from: '[email protected]', + subject: 'Welcome to CoinOS', + html: html + }); + return sendgrid.send(email); }); - return sendgrid.send(email); }); - }); + } }); }, edit: function(req, res) { @@ -193,7 +195,7 @@ return res.redirect("/" + req.params.user); } }); - if ((req.body.privkey != null) && req.body.privkey !== '' && req.body.email !== '') { + if (process.env.NODE_ENV === 'production' && (req.body.privkey != null) && req.body.privkey !== '' && req.body.email !== '') { return res.render('users/key', { user: req.params.user, layout: 'mail', |
