Skip to content

Commit

Permalink
Require reCAPTCHA to create person records. #779
Browse files Browse the repository at this point in the history
  • Loading branch information
ryosuketc committed Sep 15, 2021
1 parent 1f52fdd commit 01d4fd9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import photo
from utils import *
from detect_spam import SpamDetector
from recaptcha.client import captcha
import subscribe
import simplejson

Expand Down Expand Up @@ -385,11 +386,25 @@ def get(self):
add_profile_icon_url(website, self.transitionary_get_url)
for website in self.config.profile_websites or []]
self.render('create.html',
captcha_html=self.get_captcha_html(),
profile_websites=profile_websites,
profile_websites_json=simplejson.dumps(profile_websites),
onload_function='view_page_loaded')

def post(self):
captcha_response = self.get_captcha_response()
if not captcha_response.is_valid:
self.params.create_mode = True
profile_websites = [
add_profile_icon_url(website, self.transitionary_get_url)
for website in self.config.profile_websites or []]
self.render('create.html',
captcha_html=self.get_captcha_html(),
profile_websites=profile_websites,
profile_websites_json=simplejson.dumps(profile_websites),
onload_function='view_page_loaded')
return

profile_urls = [self.params.profile_url1,
self.params.profile_url2,
self.params.profile_url3]
Expand Down
6 changes: 6 additions & 0 deletions app/resources/add_note_base.html.template
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@
</div>
{% endif %}

{% if enable_recaptcha %}
<div class="recaptcha-card">
{{captcha_html|safe}}
</div>
{% endif %}

<div class="submit button button-blue">
<input type="submit"
{% if person.notes_disabled %}
Expand Down
2 changes: 1 addition & 1 deletion app/resources/create.html.template
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@
</div>

{% ifequal params.role "provide" %}
{% include "add_note_base.html.template" %}
{% include "add_note_base.html.template" with enable_recaptcha=True %}
{% endifequal %}

{% ifnotequal params.role "provide" %}
Expand Down

0 comments on commit 01d4fd9

Please sign in to comment.