-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reCaptcha support #2
Conversation
use `http.Handler` wrappers to split the sendmail handler into 2 distinct handlers: one for validating the query (currently, checking the allowed domains) and the other one for the sendmail functionality.
yo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ccamel ,
I gave a try to the PR, it works very well. 👍
I would suggest the following changes:
- remove the template file samples/hugo-partial-sample-form-recaptcha.html, and,
- include the content to the default template as HTML comments, as below
I think that make it easy to integrate
<div id="reply-message"></div>
<div>
<fieldset>
<legend>Please fill in the form to submit your request</legend>
<form action="https://contact-request-endpoint/" method="post">
<!-- uncomment this div block when enabling reCaptcha
<script src="https://www.google.com/recaptcha/api.js"></script>
-->
<div class="form-item">
<label for="name">Name</label>
<input type="text" name="name" id="name" placeholder="Mr. Smith" />
</div>
<div class="form-item">
<label for="email">Email <span class="req"></span></label>
<input type="text" name="email" id="email" class="required email" placeholder="[email protected]" />
</div>
<div class="form-item">
<label for="organization">Organization</label>
<input type="text" name="organization" id="organization" placeholder="Company, Inc." />
</div>
{{ if in .Params.tags "contact" }}
<div class="form-item">
<label for="subject">Subject</label>
<input type="text" name="subject" id="subject" value="" placeholder="Need help or expertise?" />
<input type="hidden" name="target" id="target" value="contact" />
</div>
<div class="form-item">
<label for="message">Message</label>
<textarea rows="6" name="message" id="message" placeholder="Please add details concerning your request."></textarea>
</div>
{{ else }}
<div class="form-item">
<input type="hidden" name="subject" id="subject" value="Your Access to Product Demo!" />
<input type="hidden" name="target" id="target" value="demo" />
</div>
{{ end }}
<!-- uncomment the below div when enabling reCaptcha
<div class="g-recaptcha" data-sitekey="{{.Site.Params.reCaptchaPrivateKey}}"></div>
-->
<input class="button" type="submit" value="Submit">
</form>
</fieldset>
</div>
07ff0c5
to
17082f3
Compare
@rchakode I agree! I've made the change in that way. 😌 |
This PR adds reCaptcha support as an additional security layer against unwanted / spam form submission.
This is a fairly straighforward implementation which verifies the challenge code in the
g-recaptcha-response
POST parameter, if available.Feel free to make any comment on this one. 😌