Skip to content

Commit

Permalink
email check
Browse files Browse the repository at this point in the history
  • Loading branch information
A. Vatsaev committed Oct 24, 2016
1 parent 8330ac6 commit b5d415f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 24 deletions.
35 changes: 23 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -283,4 +294,4 @@ function slackin(_ref) {
});

return srv;
} // es6 runtime requirements
}
42 changes: 30 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)


})
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b5d415f

Please sign in to comment.