mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-10 23:17:37 +01:00
Add simple captcha
This commit is contained in:
parent
3612c1747e
commit
c0719fdeaa
@ -102,14 +102,19 @@ def logout():
|
|||||||
class RegisterForm(FlaskForm):
|
class RegisterForm(FlaskForm):
|
||||||
display_name = StringField("Display Name", [Optional(), Length(1, 20)], filters=[lambda x: nonEmptyOrNone(x)])
|
display_name = StringField("Display Name", [Optional(), Length(1, 20)], filters=[lambda x: nonEmptyOrNone(x)])
|
||||||
username = StringField("Username", [InputRequired(),
|
username = StringField("Username", [InputRequired(),
|
||||||
Regexp("^[a-zA-Z0-9._-]+$", message="Only a-zA-Z0-9._ allowed")])
|
Regexp("^[a-zA-Z0-9._-]+$", message="Only a-zA-Z0-9._ allowed")])
|
||||||
email = StringField("Email", [InputRequired(), Email()])
|
email = StringField("Email", [InputRequired(), Email()])
|
||||||
password = PasswordField("Password", [InputRequired(), Length(6, 100)])
|
password = PasswordField("Password", [InputRequired(), Length(6, 100)])
|
||||||
agree = BooleanField("I agree", [Required()])
|
question = StringField("What is the result of the above calculation?", [InputRequired()])
|
||||||
submit = SubmitField("Register")
|
agree = BooleanField("I agree", [DataRequired()])
|
||||||
|
submit = SubmitField("Register")
|
||||||
|
|
||||||
|
|
||||||
def handle_register(form):
|
def handle_register(form):
|
||||||
|
if form.question.data.strip().lower() != "19":
|
||||||
|
flash("Incorrect captcha answer", "danger")
|
||||||
|
return
|
||||||
|
|
||||||
user_by_name = User.query.filter(or_(
|
user_by_name = User.query.filter(or_(
|
||||||
User.username == form.username.data,
|
User.username == form.username.data,
|
||||||
User.username == form.display_name.data,
|
User.username == form.display_name.data,
|
||||||
@ -168,7 +173,8 @@ def register():
|
|||||||
if ret:
|
if ret:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
return render_template("users/register.html", form=form, suggested_password=genphrase(entropy=52, wordset="bip39"))
|
return render_template("users/register.html", form=form,
|
||||||
|
suggested_password=genphrase(entropy=52, wordset="bip39"))
|
||||||
|
|
||||||
|
|
||||||
class ForgotPasswordForm(FlaskForm):
|
class ForgotPasswordForm(FlaskForm):
|
||||||
|
BIN
app/public/static/puzzle.png
Normal file
BIN
app/public/static/puzzle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@ -32,6 +32,11 @@ Register
|
|||||||
<code>{{ suggested_password }}</code>
|
<code>{{ suggested_password }}</code>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<img src="/static/puzzle.png" />
|
||||||
|
</p>
|
||||||
|
{{ render_field(form.question, hint=_("Please prove that you are human")) }}
|
||||||
|
|
||||||
{% set label %}
|
{% set label %}
|
||||||
{{ _("I agree to the ") }}
|
{{ _("I agree to the ") }}
|
||||||
<a href="{{ url_for('flatpage', path='privacy_policy') }} ">
|
<a href="{{ url_for('flatpage', path='privacy_policy') }} ">
|
||||||
|
Loading…
Reference in New Issue
Block a user