diff --git a/lastuser_oauth/forms/login.py b/lastuser_oauth/forms/login.py index 4479778..3de6307 100644 --- a/lastuser_oauth/forms/login.py +++ b/lastuser_oauth/forms/login.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from flask import Markup, url_for, current_app, escape -import flask_wtf as wtf from coaster.utils import valid_username from baseframe import _, __ import baseframe.forms as forms @@ -36,7 +35,7 @@ def validate_password(self, field): self.user = user -class RegisterForm(forms.Form): +class RegisterForm(forms.RecaptchaForm): fullname = forms.StringField(__("Full name"), validators=[forms.validators.DataRequired()]) email = forms.EmailField(__("Email address"), validators=[forms.validators.DataRequired(), forms.validators.ValidEmail()], widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}) @@ -46,7 +45,6 @@ class RegisterForm(forms.Form): password = forms.PasswordField(__("Password"), validators=[forms.validators.DataRequired()]) confirm_password = forms.PasswordField(__("Confirm password"), validators=[forms.validators.DataRequired(), forms.validators.EqualTo('password')]) - recaptcha = wtf.RecaptchaField(__("Are you human?")) def validate_username(self, field): if field.data in current_app.config['RESERVED_USERNAMES']: diff --git a/lastuser_oauth/forms/profile.py b/lastuser_oauth/forms/profile.py index b8b965b..e3b6f38 100644 --- a/lastuser_oauth/forms/profile.py +++ b/lastuser_oauth/forms/profile.py @@ -10,7 +10,7 @@ timezones = sorted_timezones() -class PasswordResetRequestForm(forms.Form): +class PasswordResetRequestForm(forms.RecaptchaForm): username = forms.StringField(__("Username or Email"), validators=[forms.validators.DataRequired()], widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}) @@ -21,7 +21,7 @@ def validate_username(self, field): self.user = user -class PasswordResetForm(forms.Form): +class PasswordResetForm(forms.RecaptchaForm): username = forms.StringField(__("Username or Email"), validators=[forms.validators.DataRequired()], description=__("Please reconfirm your username or email address"), widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}) diff --git a/lastuser_oauth/views/login.py b/lastuser_oauth/views/login.py index ee96b1f..9d2d6d6 100644 --- a/lastuser_oauth/views/login.py +++ b/lastuser_oauth/views/login.py @@ -148,9 +148,6 @@ def register(): if current_auth.is_authenticated: return redirect(url_for('index')) form = RegisterForm() - # Make Recaptcha optional - if not (current_app.config.get('RECAPTCHA_PUBLIC_KEY') and current_app.config.get('RECAPTCHA_PRIVATE_KEY')): - del form.recaptcha form.fullname.description = current_app.config.get('FULLNAME_REASON') form.email.description = current_app.config.get('EMAIL_REASON') form.username.description = current_app.config.get('USERNAME_REASON') @@ -220,7 +217,6 @@ def reset(): it may have landed in your spam or junk folder. The reset link is valid for 24 hours. """.format(masked_email=mask_email(email)))) - return render_form(form=form, title=_("Reset password"), message=message, submit=_("Send reset code"), ajax=False) diff --git a/lastuser_ui/forms/profile.py b/lastuser_ui/forms/profile.py index 3a7278a..ce1ccd5 100644 --- a/lastuser_ui/forms/profile.py +++ b/lastuser_ui/forms/profile.py @@ -12,7 +12,7 @@ 'NewPhoneForm', 'PhonePrimaryForm', 'VerifyPhoneForm'] -class NewEmailAddressForm(forms.Form): +class NewEmailAddressForm(forms.RecaptchaForm): email = forms.EmailField(__("Email address"), validators=[forms.validators.DataRequired(), forms.ValidEmail()], widget_attrs={'autocorrect': 'none', 'autocapitalize': 'none'}) type = forms.RadioField(__("Type"), coerce=nullstr, validators=[forms.validators.Optional()], choices=[ @@ -43,7 +43,7 @@ class VerifyEmailForm(forms.Form): pass -class NewPhoneForm(forms.Form): +class NewPhoneForm(forms.RecaptchaForm): phone = forms.TelField(__("Phone number"), default='+91', validators=[forms.validators.DataRequired()], description=__("Mobile numbers only at this time. Please prefix with '+' and country code.")) diff --git a/lastuser_ui/views/profile.py b/lastuser_ui/views/profile.py index 323b81e..d71de2f 100644 --- a/lastuser_ui/views/profile.py +++ b/lastuser_ui/views/profile.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from flask import flash, render_template, url_for, request, redirect +from flask import flash, render_template, url_for, request, redirect, current_app from coaster.auth import current_auth from coaster.views import load_model from baseframe import _