Skip to content

Commit

Permalink
Fix recaptcha
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Apr 15, 2019
1 parent 4ffbd46 commit 2b5a191
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ckan/lib/captcha.py
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
@@ -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>

0 comments on commit 2b5a191

Please sign in to comment.