1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

Captcha fallback for where re-captcha is unavailable (#38)

This commit is contained in:
Stefan Pratter
2019-05-02 17:57:55 +00:00
parent 7b1861a58d
commit e49d7c9b68
12 changed files with 183 additions and 31 deletions

View File

@@ -8,6 +8,9 @@ PeeringDB = {
fac : {},
ix : {}
},
recaptcha_loaded : function() {
return (typeof grecaptcha == "object");
},
init : function() {
this.InlineSearch.init_search();
@@ -25,8 +28,25 @@ PeeringDB = {
});
$('#form-create-account').on('export', function(e, data) {
data.recaptcha = grecaptcha.getResponse();
});
if(this.recaptcha_loaded()){
data.recaptcha = grecaptcha.getResponse();
} else {
data.captcha = $('#id_captcha_generator_0').val()+":"+$('#id_captcha_generator_1').val()
}
}.bind(this));
setTimeout(function() {
var fallback = $('#form-create-account').find('.fallback');
if(!this.recaptcha_loaded()) {
console.log("re-captcha could not be loaded, falling back to internal captcha");
$('#form-create-account').find('.recaptcha').hide();
fallback.show();
} else {
// since re-captcha loaded successfully we don't need a requirement
// on the fallback input
fallback.find('#id_captcha_0').attr('required', false);
}
}.bind(this), 3000);
this.fix_list_offsets();