title: Validating captcha along with passport.js
body: <p>Is it possible to verify if google recaptcha succeeded before calling passport.js authenticate function?</p>
  
  <p>I'm getting stuck between choosing one or the other because both use asynchronous callbacks to verify and I can't next them within each other.</p>
  
  <pre><code>    function verifyRecaptcha(key, rq, rs, pa, callback) {
      https.get('https://www.google.com/recaptcha/api/siteverify?secret=' + SECRET + '&amp;response=' + key, function (res) {
          var data = '';
          res.on('data', function (chunk) {
              data += chunk.toString();
          });
          res.on('end', function () {
              try {
                  var parsedData = JSON.parse(data);
  //                    return true;
                  callback(parsedData.success, rq, rs, pa);
              } catch (e) {
  //                    return false;
                  callback(false, rq, rs, pa);
              }
          });
      });
  }
  
      app.post('/auth/signin', can_access.if_not_logged_in(), passport.setupLocalStrategy(),
      function (req, res) {
          console.log('HERE');
  
          verifyRecaptcha(req.body['g-recaptcha-response'], function (success) {
              if (success) {
                  // find a way to signal captcha succeeded.
                  return true;
              } else {
                  res.end('Captcha failed, sorry.');
                  // TODO: take them back to the previous page
                  // and for the love of everyone, restore their inputs
                  return false;
              }
          });
      },
      passport.authenticate('local', {
          successRedirect: '/',
          failureRedirect: 'auth/signin',
          failureFlash: true
      }));
  </code></pre>
  
  <p>I want to do authentication after captcha has succeeded</p>