mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
use recaptcha 2 instead of 3 as it's easier to integrate
This commit is contained in:
parent
69a1f6316e
commit
47cdf79b20
4 changed files with 8 additions and 7 deletions
|
@ -1,9 +1,8 @@
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm, RecaptchaField
|
||||||
from wtforms import StringField, PasswordField, SubmitField, HiddenField
|
from wtforms import StringField, PasswordField, SubmitField, HiddenField
|
||||||
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length
|
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length
|
||||||
from flask_babel import _, lazy_gettext as _l
|
from flask_babel import _, lazy_gettext as _l
|
||||||
from app.models import User, Community
|
from app.models import User, Community
|
||||||
from app.auth.recaptcha3 import Recaptcha3Field
|
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(FlaskForm):
|
class LoginForm(FlaskForm):
|
||||||
|
@ -20,7 +19,7 @@ class RegistrationForm(FlaskForm):
|
||||||
password2 = PasswordField(
|
password2 = PasswordField(
|
||||||
_l('Repeat password'), validators=[DataRequired(),
|
_l('Repeat password'), validators=[DataRequired(),
|
||||||
EqualTo('password')])
|
EqualTo('password')])
|
||||||
recaptcha = Recaptcha3Field(action="TestAction", execute_on_load=True)
|
recaptcha = RecaptchaField()
|
||||||
|
|
||||||
submit = SubmitField(_l('Register'))
|
submit = SubmitField(_l('Register'))
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,6 @@ def register():
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
return redirect(url_for('main.index'))
|
return redirect(url_for('main.index'))
|
||||||
form = RegistrationForm()
|
form = RegistrationForm()
|
||||||
if current_app.config['MODE'] == 'development':
|
|
||||||
del form.recaptcha
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
if form.email.data == '': # ignore any registration where the email field is filled out. spam prevention
|
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 \
|
if form.real_email.data.lower().startswith('postmaster@') or form.real_email.data.lower().startswith('abuse@') or \
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% from 'bootstrap/form.html' import render_form %}
|
{% from 'bootstrap/form.html' import render_form %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src='https://www.google.com/recaptcha/api.js' async defer nonce="{{ session['nonce'] }}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block app_content %}
|
{% block app_content %}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -16,8 +16,8 @@ class Config(object):
|
||||||
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
||||||
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
|
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
|
||||||
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||||
RECAPTCHA3_PUBLIC_KEY = os.environ.get("RECAPTCHA3_PUBLIC_KEY")
|
RECAPTCHA_PUBLIC_KEY = os.environ.get("RECAPTCHA_PUBLIC_KEY")
|
||||||
RECAPTCHA3_PRIVATE_KEY = os.environ.get("RECAPTCHA3_PRIVATE_KEY")
|
RECAPTCHA_PRIVATE_KEY = os.environ.get("RECAPTCHA_PRIVATE_KEY")
|
||||||
MODE = os.environ.get('MODE') or 'development'
|
MODE = os.environ.get('MODE') or 'development'
|
||||||
LANGUAGES = ['en']
|
LANGUAGES = ['en']
|
||||||
FULL_AP_CONTEXT = os.environ.get('FULL_AP_CONTEXT') or True
|
FULL_AP_CONTEXT = os.environ.get('FULL_AP_CONTEXT') or True
|
||||||
|
|
Loading…
Add table
Reference in a new issue