mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-05 22:56:20 +01:00
Added Google reCaptcha (#738)
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings
|
||||
import re
|
||||
|
||||
|
||||
@@ -9,6 +10,10 @@ class LoginForm(forms.Form):
|
||||
username = forms.CharField(label=_('Username'), max_length=32, required=True)
|
||||
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput())
|
||||
|
||||
if getattr(settings, 'CAPTCHA_ENABLED', False):
|
||||
from captcha.fields import ReCaptchaField
|
||||
captcha = ReCaptchaField()
|
||||
|
||||
|
||||
class RegistrationForm(forms.Form):
|
||||
username = forms.CharField(label=_('Username'), max_length=30, required=True)
|
||||
@@ -17,6 +22,10 @@ class RegistrationForm(forms.Form):
|
||||
email = forms.CharField(label=_('Email'), max_length=254, required=True)
|
||||
email_again = forms.CharField(label=_('Email Again'), max_length=254, required=True)
|
||||
|
||||
if getattr(settings, 'CAPTCHA_ENABLED', False):
|
||||
from captcha.fields import ReCaptchaField
|
||||
captcha = ReCaptchaField()
|
||||
|
||||
def clean(self):
|
||||
if ' ' in self.cleaned_data['username']:
|
||||
raise forms.ValidationError('Username cannot contain a space')
|
||||
|
||||
Reference in New Issue
Block a user