Skip to content

Commit

Permalink
[#1070] Makes recaptcha work with the jinja2 templates
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Oct 2, 2013
1 parent 8ba03bb commit 2e0266f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ckan/lib/app_globals.py
Expand Up @@ -38,7 +38,7 @@
# has been setup in load_environment():
'ckan.site_id': {},
'ckan.recaptcha.publickey': {'name': 'recaptcha_publickey'},
'ckan.recaptcha.privatekey': {'name': 'recaptcha_publickey'},
'ckan.recaptcha.privatekey': {'name': 'recaptcha_privatekey'},

This comment has been minimized.

Copy link
@rufuspollock

rufuspollock Oct 11, 2013

Member

This is a real bug here ;-)

BTW: why do we need to get recaptcha_privatekey into app globals at all? Is it used anywhere in the templates? If not it would be better not to set it at all IMO and avoid risk of somehow exposing it ...

'ckan.template_title_deliminater': {'default': '-'},
'ckan.template_head_end': {},
'ckan.template_footer_end': {},
Expand Down
5 changes: 5 additions & 0 deletions ckan/public/base/less/forms.less
Expand Up @@ -670,3 +670,8 @@ textarea {
.box-shadow(none);
}
}

#recaptcha_table {
table-layout: inherit;
line-height: 1;
}
5 changes: 5 additions & 0 deletions ckan/templates/user/new_user_form.html
Expand Up @@ -7,6 +7,11 @@
{{ form.input("email", id="field-email", label=_("Email"), type="email", placeholder="joe@example.com", value=data.email, error=errors.email, classes=["control-medium"]) }}
{{ form.input("password1", id="field-password", label=_("Password"), type="password", placeholder="••••••••", value=data.password1, error=errors.password1, classes=["control-medium"]) }}
{{ form.input("password2", id="field-confirm-password", label=_("Confirm"), type="password", placeholder="••••••••", value=data.password2, error=errors.password1, classes=["control-medium"]) }}

{% if g.recaptcha_publickey %}
{% snippet "user/snippets/recaptcha.html", public_key=g.recaptcha_publickey %}
{% endif %}

<div class="form-actions">
<button class="btn btn-primary" type="submit" name="save">{{ _("Create Account") }}</button>
</div>
Expand Down
12 changes: 12 additions & 0 deletions ckan/templates/user/snippets/recaptcha.html
@@ -0,0 +1,12 @@
<div class="control-group">
<div class="controls">

<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k={{ public_key }}"></script>
<noscript>
<iframe src="http://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>

</div>
</div>

0 comments on commit 2e0266f

Please sign in to comment.