diff --git a/dist/index.js b/dist/index.js index b8bce56..f6b7378 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61,10 +61,11 @@ var _log2 = _interopRequireDefault(_log); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -// our code - - // their code +var emailCheck = require('email-check'); + +// our code +// es6 runtime requirements function slackin(_ref) { var token = _ref.token; var _ref$interval = _ref.interval; @@ -195,13 +196,6 @@ function slackin(_ref) { ///////////////////////////////////////////////////////////////////////// - - var captcha_data = { - secret: gcaptcha_secret, - response: captcha_response, - remoteip: req.connection.remoteAddress - }; - var captcha_callback = function captcha_callback(err, resp) { if (err) { @@ -232,7 +226,24 @@ function slackin(_ref) { } }; - _superagent2.default.post('https://www.google.com/recaptcha/api/siteverify').type('form').send(captcha_data).end(captcha_callback); + var email_check_callback = function email_check_callback(email_is_valid) { + + if (email_is_valid) { + + var captcha_data = { + secret: gcaptcha_secret, + response: captcha_response, + remoteip: req.connection.remoteAddress + }; + + _superagent2.default.post('https://www.google.com/recaptcha/api/siteverify').type('form').send(captcha_data).end(captcha_callback); + } else { + + return res.status(200).json({ msg: 'WOOT. Check your email!!' }); + } + }; + + emailCheck(email).then(email_check_callback); }); // iframe @@ -283,4 +294,4 @@ function slackin(_ref) { }); return srv; -} // es6 runtime requirements \ No newline at end of file +} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 684625f..4df9a25 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,6 +10,7 @@ import remail from 'email-regex' import dom from 'vd' import cors from 'cors' import request from 'superagent'; +var emailCheck = require('email-check'); // our code import Slack from './slack' @@ -158,14 +159,6 @@ export default function slackin ({ ///////////////////////////////////////////////////////////////////////// - - const captcha_data = { - secret: gcaptcha_secret, - response: captcha_response, - remoteip: req.connection.remoteAddress - } - - const captcha_callback = (err, resp) => { if (err) { @@ -211,10 +204,35 @@ export default function slackin ({ } - request.post('https://www.google.com/recaptcha/api/siteverify') - .type('form') - .send(captcha_data) - .end(captcha_callback); + const email_check_callback = (email_is_valid) => { + + if(email_is_valid){ + + const captcha_data = { + secret: gcaptcha_secret, + response: captcha_response, + remoteip: req.connection.remoteAddress + } + + + + request.post('https://www.google.com/recaptcha/api/siteverify') + .type('form') + .send(captcha_data) + .end(captcha_callback); + + + }else{ + + return res + .status(200) + .json({ msg: 'WOOT. Check your email!!' }) + + } + } + + + emailCheck(email).then(email_check_callback) }) diff --git a/package.json b/package.json index 563d46b..bedf11e 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "body-parser": "1.10.2", "cors": "2.7.1", "debug": "2.1.1", + "email-check": "^1.1.0", "email-regex": "1.0.0", "express": "4.11.0", "hostenv": "1.0.1",