new: Fake field to avoid dumb bots

pull/208/head
Raphaël Vinot 2021-05-25 13:20:24 -07:00
parent 240edc97dc
commit 8a5b1f263e
3 changed files with 20 additions and 0 deletions

View File

@ -475,6 +475,10 @@ def cache_tree(tree_uuid: str):
def send_mail(tree_uuid: str): def send_mail(tree_uuid: str):
if not enable_mail_notification: if not enable_mail_notification:
return redirect(url_for('tree', tree_uuid=tree_uuid)) return redirect(url_for('tree', tree_uuid=tree_uuid))
if request.form.get('name'):
# got a bot.
logging.info(f'{src_request_ip(request)} is a bot - {request.headers.get("User-Agent")}.')
return redirect('https://www.youtube.com/watch?v=iwGFalTRHDA')
email: str = request.form['email'] if request.form.get('email') else '' email: str = request.form['email'] if request.form.get('email') else ''
if '@' not in email: if '@' not in email:
# skip clearly incorrect emails # skip clearly incorrect emails

View File

@ -85,3 +85,14 @@ table td p {
padding: 5px; padding: 5px;
width: 150px; width: 150px;
} }
/* boaty */
.boatymcboat {
opacity: 0;
position: absolute;
top: 0;
left: 0;
height: 0;
width: 0;
z-index: -1;
}

View File

@ -488,6 +488,11 @@
<div class="form-group"> <div class="form-group">
<label for="email">Email address - used to get back in touch with you if needed (optional)</label> <label for="email">Email address - used to get back in touch with you if needed (optional)</label>
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email"> <input type="email" class="form-control" name="email" id="email" placeholder="Enter email">
<!-- boat fields -->
<label class="boatymcboat" for="name">Your Name</label>
<input class="boatymcboat" autocomplete="off" type="text" id="name" name="name"
placeholder="Your fav boat name here">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="comment">Please write a comment (optional)</label> <label for="comment">Please write a comment (optional)</label>