mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add simple captcha
This commit is contained in:
parent
3612c1747e
commit
c0719fdeaa
@ -102,14 +102,19 @@ def logout():
|
||||
class RegisterForm(FlaskForm):
|
||||
display_name = StringField("Display Name", [Optional(), Length(1, 20)], filters=[lambda x: nonEmptyOrNone(x)])
|
||||
username = StringField("Username", [InputRequired(),
|
||||
Regexp("^[a-zA-Z0-9._-]+$", message="Only a-zA-Z0-9._ allowed")])
|
||||
email = StringField("Email", [InputRequired(), Email()])
|
||||
Regexp("^[a-zA-Z0-9._-]+$", message="Only a-zA-Z0-9._ allowed")])
|
||||
email = StringField("Email", [InputRequired(), Email()])
|
||||
password = PasswordField("Password", [InputRequired(), Length(6, 100)])
|
||||
agree = BooleanField("I agree", [Required()])
|
||||
submit = SubmitField("Register")
|
||||
question = StringField("What is the result of the above calculation?", [InputRequired()])
|
||||
agree = BooleanField("I agree", [DataRequired()])
|
||||
submit = SubmitField("Register")
|
||||
|
||||
|
||||
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.username == form.username.data,
|
||||
User.username == form.display_name.data,
|
||||
@ -168,7 +173,8 @@ def register():
|
||||
if 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):
|
||||
|
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>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img src="/static/puzzle.png" />
|
||||
</p>
|
||||
{{ render_field(form.question, hint=_("Please prove that you are human")) }}
|
||||
|
||||
{% set label %}
|
||||
{{ _("I agree to the ") }}
|
||||
<a href="{{ url_for('flatpage', path='privacy_policy') }} ">
|
||||
|
Loading…
Reference in New Issue
Block a user