Use Floens's trick to get Recaptcha v1 working again.
This commit is contained in:
parent
aef754e224
commit
d616d864eb
@ -1,9 +1,17 @@
|
|||||||
QR.captcha =
|
QR.captcha =
|
||||||
init: ->
|
init: ->
|
||||||
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
return if d.cookie.indexOf('pass_enabled=1') >= 0
|
||||||
return unless @isEnabled = !!$.id 'captchaContainer'
|
return unless @isEnabled = !!$.id 'g-recaptcha'
|
||||||
|
|
||||||
$.globalEval 'loadRecaptcha()' if Conf['Auto-load captcha']
|
script = $.el 'script',
|
||||||
|
src: '//www.google.com/recaptcha/api/js/recaptcha_ajax.js'
|
||||||
|
$.add d.head, script
|
||||||
|
captchaContainer = $.el 'div',
|
||||||
|
id: 'captchaContainer'
|
||||||
|
hidden: true
|
||||||
|
$.add d.body, captchaContainer
|
||||||
|
|
||||||
|
@setup() if Conf['Auto-load captcha']
|
||||||
|
|
||||||
imgContainer = $.el 'div',
|
imgContainer = $.el 'div',
|
||||||
className: 'captcha-img'
|
className: 'captcha-img'
|
||||||
@ -44,7 +52,20 @@ QR.captcha =
|
|||||||
@count()
|
@count()
|
||||||
$.on input, 'focus', @setup
|
$.on input, 'focus', @setup
|
||||||
setup: ->
|
setup: ->
|
||||||
$.globalEval 'loadRecaptcha()'
|
$.globalEval '''
|
||||||
|
(function() {
|
||||||
|
var captchaContainer = document.getElementById("captchaContainer");
|
||||||
|
if (captchaContainer.firstChild) return;
|
||||||
|
function setup() {
|
||||||
|
if (window.Recaptcha) {
|
||||||
|
Recaptcha.create(recaptchaKey, captchaContainer, {theme: "clean"});
|
||||||
|
} else {
|
||||||
|
setTimeout(setup, 25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setup();
|
||||||
|
})()
|
||||||
|
'''
|
||||||
afterSetup: ->
|
afterSetup: ->
|
||||||
return unless challenge = $.id 'recaptcha_challenge_field_holder'
|
return unless challenge = $.id 'recaptcha_challenge_field_holder'
|
||||||
return if challenge is QR.captcha.nodes.challenge
|
return if challenge is QR.captcha.nodes.challenge
|
||||||
@ -88,6 +109,10 @@ QR.captcha =
|
|||||||
challenge = @nodes.img.alt
|
challenge = @nodes.img.alt
|
||||||
if response = @nodes.input.value
|
if response = @nodes.input.value
|
||||||
if Conf['Auto-load captcha'] then @reload() else @destroy()
|
if Conf['Auto-load captcha'] then @reload() else @destroy()
|
||||||
|
# Duplicate one-word captchas.
|
||||||
|
# Don't duplicate street numbers for now (needs testing).
|
||||||
|
if response and !/\s|^\d$/.test response
|
||||||
|
response = "#{response} #{response}"
|
||||||
{challenge, response}
|
{challenge, response}
|
||||||
|
|
||||||
save: ->
|
save: ->
|
||||||
|
|||||||
@ -686,7 +686,7 @@ QR =
|
|||||||
mode: 'regist'
|
mode: 'regist'
|
||||||
pwd: QR.persona.pwd
|
pwd: QR.persona.pwd
|
||||||
recaptcha_challenge_field: challenge
|
recaptcha_challenge_field: challenge
|
||||||
recaptcha_response_field: response
|
'g-recaptcha-response': response
|
||||||
|
|
||||||
options =
|
options =
|
||||||
responseType: 'document'
|
responseType: 'document'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user