[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Fix ReCaptchaProtectedResource.checkSolution() to pull response from deferred.
commit 45876ea43d4aa570d5801aed244d753624af9543
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Mon Mar 17 00:05:34 2014 +0000
Fix ReCaptchaProtectedResource.checkSolution() to pull response from deferred.
* FIXES a bug introduced in #11127 where checkSolution() was expecting the
boolean response from the reCaptcha API server, not a deferred as is now
returned.
---
lib/bridgedb/HTTPServer.py | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index 49700c5..e9abc78 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -424,19 +424,24 @@ class ReCaptchaProtectedResource(CaptchaProtectedResource):
challenge, response = self.extractClientSolution(request)
clientIP = self.getClientIP(request)
remoteIP = self.getRemoteIP()
- solution = txrecaptcha.submit(challenge, response,
- self.recaptchaPrivKey, remoteIP)
+
logging.debug("Captcha from %r. Parameters: %r"
% (Util.logSafely(clientIP), request.args))
- if solution.is_valid:
- logging.info("Valid CAPTCHA solution from %r."
- % Util.logSafely(clientIP))
- return True
- else:
- logging.info("Invalid CAPTCHA solution from %r: %r"
- % (Util.logSafely(clientIP), solution.error_code))
- return False
+
+ def checkResponse(solution, clientIP):
+ if solution.is_valid:
+ logging.info("Valid CAPTCHA solution from %r."
+ % Util.logSafely(clientIP))
+ return True
+ else:
+ logging.info("Invalid CAPTCHA solution from %r: %r"
+ % (Util.logSafely(clientIP), solution.error_code))
+ return False
+
+ d = txrecaptcha.submit(challenge, response, self.recaptchaPrivKey,
+ remoteIP).addCallback(checkResponse, clientIP)
+ return d
def render_GET(self, request):
"""Retrieve a ReCaptcha from the API server and serve it to the client.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits