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

Fix recaptcha #4732

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ckan/lib/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def check_recaptcha(request):
client_ip_address = request.environ.get('REMOTE_ADDR', 'Unknown IP Address')

# reCAPTCHA v2
recaptcha_response_field = request.params.get('g-recaptcha-response', '')
recaptcha_response_field = request.form.get('g-recaptcha-response', '')
recaptcha_server_name = 'https://www.google.com/recaptcha/api/siteverify'

# recaptcha_response_field will be unicode if there are foreign chars in
Expand Down
36 changes: 13 additions & 23 deletions ckan/templates/user/snippets/recaptcha.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
<div class="form-group">
<div class="controls">
{% if g.recaptcha_version == '1' %}
<script type="text/javascript" src="//www.google.com/recaptcha/api/challenge?k={{ public_key }}"></script>

<noscript>
<iframe src="//www.google.com/recaptcha/api/noscript?k={{ public_key }}" height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>
{% elif g.recaptcha_version == '2' %}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="{{ public_key }}"></div>

<noscript>
<div style="width: 304px; height: 352px; position: relative;">
<div style="width: 304px; height: 352px; position: absolute;">
<iframe src="https://www.google.com/recaptcha/api/fallback?k={{ public_key }}" frameborder="0" scrolling="no" style="width: 304px; height:352px"></iframe>
</div>

<div style="width: 250px; height: 80px; position: absolute; bottom: 21px; left: 25px; margin: 0; padding: 0; right: 25px;">
<textarea id="g-recaptcha-response" name="g-recaptcha-response" style="width: 250px; height: 80px; border: 1px solid #c1c1c1; margin: 0; padding: 0; resize: none;" class="g-recaptcha-response"></textarea>
</div>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-sitekey="{{ public_key }}"></div>

<noscript>
<div style="width: 304px; height: 352px; position: relative;">
<div style="width: 304px; height: 352px; position: absolute;">
<iframe src="https://www.google.com/recaptcha/api/fallback?k={{ public_key }}" frameborder="0" scrolling="no" style="width: 304px; height:352px"></iframe>
</div>
</noscript>
{% endif %}

<div style="width: 250px; height: 80px; position: absolute; bottom: 21px; left: 25px; margin: 0; padding: 0; right: 25px;">
<textarea id="g-recaptcha-response" name="g-recaptcha-response" style="width: 250px; height: 80px; border: 1px solid #c1c1c1; margin: 0; padding: 0; resize: none;" class="g-recaptcha-response"></textarea>
</div>
</div>
</noscript>
</div>
</div>