Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use invisible recaptcha #224

Merged
merged 10 commits into from Jun 9, 2019
Merged

Use invisible recaptcha #224

merged 10 commits into from Jun 9, 2019

Conversation

iambibhas
Copy link
Contributor

@iambibhas iambibhas commented May 22, 2019

Fixes #143.

This essentially forces invisible recaptcha wherever RecaptchaField is used. On any client app that uses this, it's required to set this in the config -

RECAPTCHA_DATA_ATTRS = {'callback': "onInvisibleRecaptchaSubmit", 'size': "invisible"}

@iambibhas iambibhas requested a review from vidya-ram May 22, 2019 18:47
@iambibhas
Copy link
Contributor Author

@vidya-ram there is a confusion between formid and ref_id in renderform macro. formid isn't used almost anywhere. Rather ref_id is dynamically generated and used as id for <form> elements.

@iambibhas iambibhas requested a review from jace May 23, 2019 08:06
@jace
Copy link
Member

jace commented May 26, 2019

formid is submitted back to the backend as the form.id variable. It is used when the same endpoint handles multiple forms, to identify which was submitted. It is only used in the frontend to create a hidden input field, with name="form.id" value="{{ formid }}". As a value rather than an id, it is not useful in JavaScript.

You need ref_id here.

Copy link
Member

@jace jace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If you must change the method signature, issue PRs in every repo that calls the method.

  2. We're maintaining feature parity with the Bootstrap templates since they are not discontinued until all the Bootstrap apps have been shut down or migrated.

@@ -101,13 +101,26 @@
{%- endif %}
{%- endmacro %}

{% macro rendersubmit(buttons=[], css_class="", tabindex='', cancel_url='', style='horiz', csrf_error=false) -%}
{% macro rendersubmit(form, ref_id, buttons=[], css_class="", tabindex='', cancel_url='', style='horiz', csrf_error=false) -%}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the parameters will break a lot of code. Add this to the end as optional values. https://github.com/search?q=org%3Ahasgeek+rendersubmit&type=Code

document.getElementById("{{ ref_id }}").submit();
}
}
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be added to widgetscripts macro and form, ref_id need not be included as parameters in rendersubmit

@iambibhas
Copy link
Contributor Author

Added the scripts to widgetscript and no longer modifying submit button.

@jace
Copy link
Member

jace commented Jun 3, 2019

On any client app that uses this, it's required to set this in the config -

RECAPTCHA_DATA_ATTRS = {'callback': "onInvisibleRecaptchaSubmit", 'size': "invisible"}

If this is required everywhere, why is this config? It should be just code.

@jace jace changed the title Invoking recaptcha on submit button click if form has recaptcha field Use invisible recaptcha Jun 9, 2019
@jace jace merged commit 3774cc7 into master Jun 9, 2019
@jace jace deleted the invisible-recaptcha-field branch June 9, 2019 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invisible reCAPTCHA field
3 participants