From 2aaf20b42bd729b33fdbd69e8cff800db156502f Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Wed, 23 Sep 2015 11:47:23 -0400 Subject: [PATCH] Recaptcha for teams signup. --- settings_local.py-template | 1 + templates/base.html | 2 ++ templates/for-teams-complete.html | 2 +- templates/for-teams.html | 3 ++- views.py | 12 ++++++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/settings_local.py-template b/settings_local.py-template index aed01ed..336d080 100644 --- a/settings_local.py-template +++ b/settings_local.py-template @@ -3,6 +3,7 @@ DEBUG = True INTERCOM_SECRET_KEY = '' POSTMARK_API_KEY = '' RAVEN_CONFIG = {'dsn': ''} +RECAPTCHA_SECRET = '' SECRET_KEY = 'changeme' SESSION_COOKIE_SECURE = False SSLIFY_DISABLE = False diff --git a/templates/base.html b/templates/base.html index 757f78d..1e62f01 100644 --- a/templates/base.html +++ b/templates/base.html @@ -65,6 +65,8 @@ + + diff --git a/templates/for-teams-complete.html b/templates/for-teams-complete.html index d8b38da..69693e1 100644 --- a/templates/for-teams-complete.html +++ b/templates/for-teams-complete.html @@ -15,7 +15,7 @@
You rock.

- We'll email you to arrange the beta program payment of $49, and help you get your first team created!

+ We'll email you to get more information about your team and to help you get your first team created. If you ever need anything at all, email support, or use the chat in the bottom right.

diff --git a/templates/for-teams.html b/templates/for-teams.html index 41d5fa6..449bb7c 100644 --- a/templates/for-teams.html +++ b/templates/for-teams.html @@ -14,7 +14,7 @@ You've successfully applied for the beta program - we'll email you as soon as we're ready! {% else %} -
+
Snipt for Teams @@ -59,6 +59,7 @@
+
{% csrf_token %} diff --git a/views.py b/views.py index 6bb206a..48e5bc9 100644 --- a/views.py +++ b/views.py @@ -2,6 +2,7 @@ import datetime import hashlib import os import stripe +import requests from accounts.models import UserProfile from annoying.decorators import ajax_request, render_to @@ -33,6 +34,17 @@ def for_teams_complete(request): if request.method == 'POST': + payload = { + 'secret': settings.RECAPTCHA_SECRET, + 'response': request.POST['g-recaptcha-response'], + 'remoteip': request.META.get('REMOTE_ADDR') + } + r = requests.post('https://www.google.com/recaptcha/api/siteverify', + data=payload) + + if not r.json()['success']: + return HttpResponseBadRequest() + if request.user.is_authenticated(): name = request.POST['name'] members = request.POST['members']