Remove duplication of recaptcha code, which caused issues, and improved script tag logic to check for errors.
This commit is contained in:
parent
e29832c202
commit
32f95d7ae4
@ -36,11 +36,23 @@ module ApplicationHelper
|
||||
raw %Q{
|
||||
<input name="recaptcha_token" type="hidden" id="#{id}"/>
|
||||
<script>
|
||||
grecaptcha.ready(function() {
|
||||
grecaptcha.execute('#{RECAPTCHA_SITE_KEY}', {action: '#{action}'}).then(function(token) {
|
||||
document.getElementById("#{id}").value = token;
|
||||
if (typeof grecaptcha !== 'undefined') {
|
||||
grecaptcha.ready(function() {
|
||||
grecaptcha.execute('#{RECAPTCHA_SITE_KEY}', {action: '#{action}'}).then(function(token) {
|
||||
document.getElementById("#{id}").value = token;
|
||||
}).catch(function(error) {
|
||||
console.error('reCAPTCHA execution error:', error);
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
document.addEventListener('grecaptcha-ready', function() {
|
||||
grecaptcha.execute('#{RECAPTCHA_SITE_KEY}', {action: '#{action}'}).then(function(token) {
|
||||
document.getElementById("#{id}").value = token;
|
||||
}).catch(function(error) {
|
||||
console.error('reCAPTCHA execution error:', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
end
|
||||
|
||||
@ -70,8 +70,6 @@
|
||||
.message=''
|
||||
%button.close=_'modals.done_button'
|
||||
- if @login_dlg.present?
|
||||
= content_for :recaptcha_js do
|
||||
= include_recaptcha_js
|
||||
.dlg#login-dlg
|
||||
.dlg-content
|
||||
%h2.title=_'forms.actions.generic.login'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user