From 47cdf79b20ddab3097bf56623350cffa8f39ddc9 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sat, 6 Jan 2024 19:48:10 +1300 Subject: [PATCH] use recaptcha 2 instead of 3 as it's easier to integrate --- app/auth/forms.py | 5 ++--- app/auth/routes.py | 2 -- app/templates/auth/register.html | 4 ++++ config.py | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/auth/forms.py b/app/auth/forms.py index e98ca625..dcf98f65 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -1,9 +1,8 @@ -from flask_wtf import FlaskForm +from flask_wtf import FlaskForm, RecaptchaField from wtforms import StringField, PasswordField, SubmitField, HiddenField from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length from flask_babel import _, lazy_gettext as _l from app.models import User, Community -from app.auth.recaptcha3 import Recaptcha3Field class LoginForm(FlaskForm): @@ -20,7 +19,7 @@ class RegistrationForm(FlaskForm): password2 = PasswordField( _l('Repeat password'), validators=[DataRequired(), EqualTo('password')]) - recaptcha = Recaptcha3Field(action="TestAction", execute_on_load=True) + recaptcha = RecaptchaField() submit = SubmitField(_l('Register')) diff --git a/app/auth/routes.py b/app/auth/routes.py index d57ac52e..2209bdd7 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -79,8 +79,6 @@ def register(): if current_user.is_authenticated: return redirect(url_for('main.index')) form = RegistrationForm() - if current_app.config['MODE'] == 'development': - del form.recaptcha if form.validate_on_submit(): if form.email.data == '': # ignore any registration where the email field is filled out. spam prevention if form.real_email.data.lower().startswith('postmaster@') or form.real_email.data.lower().startswith('abuse@') or \ diff --git a/app/templates/auth/register.html b/app/templates/auth/register.html index 94bd5fa2..4e99578d 100644 --- a/app/templates/auth/register.html +++ b/app/templates/auth/register.html @@ -1,6 +1,10 @@ {% extends "base.html" %} {% from 'bootstrap/form.html' import render_form %} +{% block scripts %} + +{% endblock %} + {% block app_content %}