Adds Recaptcha V2 support while keeping backward compatibility#16
Open
felipou wants to merge 2 commits intomirhampt:masterfrom
Open
Adds Recaptcha V2 support while keeping backward compatibility#16felipou wants to merge 2 commits intomirhampt:masterfrom
felipou wants to merge 2 commits intomirhampt:masterfrom
Conversation
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.
|
Please can someone let me know when this is likely to be merged? Thanks |
|
is it possible that u might mix up some callback parameters in the verify method? (success, errorMessage) |
Author
|
@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. |
|
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 |
|
Just in case anyone needs it, I'm using recaptcha2 now, and it works really well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.