Recaptcha for teams signup.

master
Nick Sergeant 2015-09-23 11:47:23 -04:00
parent 14a7cfd6e1
commit 2aaf20b42b
5 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -65,6 +65,8 @@
<script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="https://www.google.com/recaptcha/api.js"></script>
</head>
<body class="{% block body-class %}{% endblock %} {% if request.user.profile.is_pro %}is-pro{% endif %}" ng-controller="AppController">

View File

@ -15,7 +15,7 @@
<div class="info">
You rock.
<p class="sub" style="padding: 0 120px;">
We'll email you to arrange the beta program payment of $49, and help you get your first team created!<br /><br />
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, <a href="mailto:support@snipt.net">email support</a>, or use the chat in the bottom right.
</p>
</div>

View File

@ -14,7 +14,7 @@
You've successfully applied for the beta program - we'll email you as soon as we're ready!
</div>
{% else %}
<form class="form-horizontal static-box" id="pro-signup" method="post" action="/for-teams/complete/">
<form class="form-horizontal static-box" id="teams-signup" method="post" action="/for-teams/complete/">
<fieldset>
<div class="info">
Snipt for Teams
@ -59,6 +59,7 @@
<textarea required name="info" name="info" id="info" class="input-xlarge" style="height: 100px;"></textarea>
</div>
</div>
<div style="margin-left: 180px;" class="g-recaptcha" data-sitekey="6LerYA0TAAAAAFJaMf7JMnlQR2wzqd_3dMRvLd-4"></div>
<div class="form-actions">
{% csrf_token %}
<button type="submit" class="btn btn-success">Request more info &raquo;</button>

View File

@ -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']