mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-13 13:12:42 +00:00
Catch and handle recaptcha API errors
Just send the user an API error and they can try again. Better than internal server error + email to webmaster... Seems to be caused by intermittent network issues.
This commit is contained in:
@ -57,10 +57,16 @@ class ReCaptchaField(forms.CharField):
|
||||
# if self.remoteip:
|
||||
# param['remoteip'] = self.remoteip
|
||||
|
||||
c.request('POST', '/recaptcha/api/siteverify', urllib.urlencode(param), {
|
||||
'Content-type': 'application/x-www-form-urlencoded',
|
||||
})
|
||||
c.sock.settimeout(10)
|
||||
try:
|
||||
c.request('POST', '/recaptcha/api/siteverify', urllib.urlencode(param), {
|
||||
'Content-type': 'application/x-www-form-urlencoded',
|
||||
})
|
||||
c.sock.settimeout(10)
|
||||
except Exception, e:
|
||||
# Error to connect at TCP level
|
||||
log.error('Failed to connect to google recaptcha API: %s' % e)
|
||||
raise ValidationError('Failed in API call to google recaptcha')
|
||||
|
||||
try:
|
||||
r = c.getresponse()
|
||||
except:
|
||||
|
Reference in New Issue
Block a user