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{
|
raw %Q{
|
||||||
<input name="recaptcha_token" type="hidden" id="#{id}"/>
|
<input name="recaptcha_token" type="hidden" id="#{id}"/>
|
||||||
<script>
|
<script>
|
||||||
|
if (typeof grecaptcha !== 'undefined') {
|
||||||
grecaptcha.ready(function() {
|
grecaptcha.ready(function() {
|
||||||
grecaptcha.execute('#{RECAPTCHA_SITE_KEY}', {action: '#{action}'}).then(function(token) {
|
grecaptcha.execute('#{RECAPTCHA_SITE_KEY}', {action: '#{action}'}).then(function(token) {
|
||||||
document.getElementById("#{id}").value = 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>
|
</script>
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@ -70,8 +70,6 @@
|
|||||||
.message=''
|
.message=''
|
||||||
%button.close=_'modals.done_button'
|
%button.close=_'modals.done_button'
|
||||||
- if @login_dlg.present?
|
- if @login_dlg.present?
|
||||||
= content_for :recaptcha_js do
|
|
||||||
= include_recaptcha_js
|
|
||||||
.dlg#login-dlg
|
.dlg#login-dlg
|
||||||
.dlg-content
|
.dlg-content
|
||||||
%h2.title=_'forms.actions.generic.login'
|
%h2.title=_'forms.actions.generic.login'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user