Add spam honeypot field to register form

This commit is contained in:
rubenwardy
2025-09-23 18:59:05 +01:00
parent b88cc1366f
commit 4db70bf401
4 changed files with 10 additions and 1 deletions

View File

@@ -104,6 +104,7 @@ class RegisterForm(FlaskForm):
email = StringField(lazy_gettext("Email"), [InputRequired(), Email()])
password = PasswordField(lazy_gettext("Password"), [InputRequired(), Length(12, 100)])
question = StringField(lazy_gettext("What is the result of the above calculation?"), [InputRequired()])
first_name = StringField("First name", [])
submit = SubmitField(lazy_gettext("Register"))
@@ -117,6 +118,8 @@ def handle_register(form):
return user
elif user is None:
return
elif form.first_name.data != "":
abort(500)
user.password = make_flask_login_password(form.password.data)

View File

@@ -283,3 +283,7 @@ blockquote {
.form-group {
margin-bottom: 1rem !important;
}
input[name="first_name"] {
display: none;
}

View File

@@ -16,7 +16,7 @@
{%- endif %}
<link rel="stylesheet" type="text/css" href="/static/libs/bootstrap.min.css?v=4">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=58">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=59">
<link rel="search" type="application/opensearchdescription+xml" href="/static/opensearch.xml" title="ContentDB" />
{% if noindex -%}

View File

@@ -34,6 +34,8 @@
</p>
{{ render_field(form.question, hint=_("Please prove that you are human")) }}
<input class="form-control" id="first_name" name="first_name" type="text" value="">
<p>
{{ _("By signing up, you agree to the <a href='/terms/' target='_blank'>Terms of Service</a> and <a href='/privacy_policy/' target='_blank'>Privacy Policy</a>.") }}
</p>