Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Recaptcha V2 support while keeping backward compatibility #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

felipou
Copy link

@felipou felipou commented Aug 28, 2015

I got the version 2 implementation from hgGeorg's fork (https://github.com/hgGeorg/node-recaptcha/blob/master/lib/recaptcha.js)
and inserted it here but keeping the lib backwards compatible so
it is possible to make a smooth transition, or even support both
versions in the same code.

I got the version 2 implementation from hgGeorg's fork (https://github.com/hgGeorg/node-recaptcha/blob/master/lib/recaptcha.js)
and inserted it here but keeping the lib backwards compatible so
it is possible to make a smooth transition, or even support both
versions in the same code.
@superclarkk
Copy link

Please can someone let me know when this is likely to be merged? Thanks

@Sommerfeld
Copy link

is it possible that u might mix up some callback parameters in the verify method? (success, errorMessage)

@felipou
Copy link
Author

felipou commented Feb 12, 2016

@Sommerfeld Sorry, I didn't understand what you want. Also, I didn't write any of this code, I just merged the codes for both versions.

@Sommerfeld
Copy link

/lib/v2.js

Recaptcha.prototype.verify = function(callback) {
    var self = this;

    // See if we can declare this invalid without even contacting Recaptcha.
    if (typeof(this.data) === 'undefined') {
        this.error_code = 'verify-params-incorrect';
        return callback('verify-params-incorrect', false); // (errorMessage, succes)
    }
    if (!('remoteip' in this.data &&
          'response' in this.data))
    {
        this.error_code = 'verify-params-incorrect';
        return callback(false, 'verify-params-incorrect'); // (success, errorMessage)
    }
    if (this.data.response === '') {
        this.error_code = 'incorrect-captcha-sol';
        return callback('incorrect-captcha-sol', false); // (errorMessage, succes)
    }
   ...
};

If i'm correct after checking /lib/v1.js it should always be (succes, errorMessage). It's not important for me just got confused when i read the code. So if I'm wrong just ignore me:)

@superclarkk
Copy link

Just in case anyone needs it, I'm using recaptcha2 now, and it works really well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants