From 42e8de7d9d667f3c2057a3f67adc66b4167c730e Mon Sep 17 00:00:00 2001 From: Tom Price Date: Sat, 25 Apr 2015 16:54:01 +0100 Subject: [PATCH] Add recaptcha to login page --- RIGS/forms.py | 5 +++++ RIGS/views.py | 2 +- templates/registration/loginform.html | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/RIGS/forms.py b/RIGS/forms.py index 134fc0bd..7a9dc854 100644 --- a/RIGS/forms.py +++ b/RIGS/forms.py @@ -3,6 +3,7 @@ from django import forms from django.utils import formats from django.conf import settings from django.core import serializers +from django.contrib.auth.forms import AuthenticationForm from registration.forms import RegistrationFormUniqueEmail from captcha.fields import ReCaptchaField import simplejson @@ -25,6 +26,10 @@ class ProfileRegistrationFormUniqueEmail(RegistrationFormUniqueEmail): raise forms.ValidationError("These initials are already in use. Please supply different initials.") return self.cleaned_data['initials'] +# Login form +class LoginForm(AuthenticationForm): + captcha = ReCaptchaField(label='Captcha') + # Events Shit class EventForm(forms.ModelForm): datetime_input_formats = formats.get_format_lazy("DATETIME_INPUT_FORMATS") + settings.DATETIME_INPUT_FORMATS diff --git a/RIGS/views.py b/RIGS/views.py index 38cbe99a..472f20ec 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -30,7 +30,7 @@ def login(request, **kwargs): else: from django.contrib.auth.views import login - return login(request) + return login(request, authentication_form=forms.LoginForm) """ diff --git a/templates/registration/loginform.html b/templates/registration/loginform.html index 01c0b900..1ad39bd7 100644 --- a/templates/registration/loginform.html +++ b/templates/registration/loginform.html @@ -1,7 +1,7 @@ {% load url from future %} {% load widget_tweaks %} {% include 'form_errors.html' %} -
+
{% csrf_token %}
@@ -12,6 +12,12 @@ {% render_field form.password class+="form-control" placeholder=form.password.label %}
+
+ +
+ {{ form.captcha }} +
+
Register Forgotten Password