[tor-commits] [newsletter/master] Added captcha and error handling to newsletter form

hiro at torproject.org hiro at torproject.org
Wed Oct 14 15:36:55 UTC 2020


commit 8fb60a284a9e96b3fcec9972cadfae458d37b912
Author: Peter Haight <peterh at giantrabbit.com>
Date:   Tue Sep 22 15:10:36 2020 -0700

    Added captcha and error handling to newsletter form
    
    There are some errors that can happen when submitting the subscription
    request and we don't want to have any styled pages on the donate site
    once we finish moving the donate pages to lektor, so we need to have the
    donate site redirect with error messages back to the original page, then
    use Javascript to get the errors displayed.
    
    Issue #48283
---
 lego                      |  2 +-
 templates/intro.html      | 22 +++++++++++++++++++---
 templates/newsletter.html |  1 +
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/lego b/lego
index 7f2289b..925c4c1 160000
--- a/lego
+++ b/lego
@@ -1 +1 @@
-Subproject commit 7f2289bf68685da40878bb09ee91346057c443d3
+Subproject commit 925c4c1761ca69c4367f79b15ed9a2bc19a19a33
diff --git a/templates/intro.html b/templates/intro.html
index 35b2726..7846fd3 100644
--- a/templates/intro.html
+++ b/templates/intro.html
@@ -30,16 +30,32 @@
 <div class="row mb-1">
   <div class="col-12">
     <div class="row mt-4 mb-2">
-      <form action="https://donate.torproject.org/subscription-request" method="POST" class="form-wide">
+      <form action="https://tor-donate.local/subscription-request" method="POST" class="form-wide">
+        <input type="hidden" name="returnToReferrer" value="1" />
         <div class="form-group row">
-          <div class="col-sm-10">
+          <div class="col-sm-12 errors">
+          </div>
+        </div>
+        <div class="form-group row">
+          <div class="col-sm-12">
             <input class="form-control form-control-lg form-required" id="email"
                 name="email" placeholder="* Email Address" value="" type="email" />
           </div>
-          <input class="donate btn btn-lg btn-success btn-block col-2" value="Join" type="submit" />
+        </div>
+        <div class="form-group row">
+          <div class="col-sm-6 captcha">
+            <input id="captcha" type="text" class="form-control form-control-lg form-required" data-name="captcha" data-stripe="captcha" aria-label="captcha" name="captcha" size="4" placeholder="* Enter the 4 letters (case insenstive) that appear below">
+            <img src="https://tor-donate.local/captcha" border="0" />
+          </div>
+        </div>
+        <div class="form-group row">
+          <div class="col-sm-12">
+            <input class="donate btn btn-lg btn-success btn-block col-2" value="Join" type="submit" />
+          </div>
         </div>
       </form>
     </div>
   </div>
 </div>
+<script src="{{ '/static/js/errors.js'|asseturl }}" ></script>
 {% endblock %}
diff --git a/templates/newsletter.html b/templates/newsletter.html
index 8772ec3..7ab7c33 100644
--- a/templates/newsletter.html
+++ b/templates/newsletter.html
@@ -2,6 +2,7 @@
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="{{ '/static/style.css'|asseturl }}">
+<script src="{{ '/static/js/errors.js'|asseturl }}"></script>
 
 <title>{% block title %}{{ this.title }}{% endblock %}</title>
 <body>





More information about the tor-commits mailing list