diff --git a/geonode/people/forms.py b/geonode/people/forms/__init__.py
similarity index 86%
rename from geonode/people/forms.py
rename to geonode/people/forms/__init__.py
index 9fbdf4ae638..2fa95de7bfb 100644
--- a/geonode/people/forms.py
+++ b/geonode/people/forms/__init__.py
@@ -24,23 +24,10 @@
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.utils.translation import gettext_lazy as _
-try:
- from captcha.fields import ReCaptchaField
-except ImportError:
- from django_recaptcha.fields import ReCaptchaField
-
# Ported in from django-registration
attrs_dict = {"class": "required"}
-class AllauthReCaptchaSignupForm(forms.Form):
- captcha = ReCaptchaField(label=False)
-
- def signup(self, request, user):
- """Required, or else it thorws deprecation warnings"""
- pass
-
-
class ProfileCreationForm(UserCreationForm):
class Meta:
model = get_user_model()
diff --git a/geonode/people/forms/recaptcha.py b/geonode/people/forms/recaptcha.py
new file mode 100644
index 00000000000..6acbc7ae58e
--- /dev/null
+++ b/geonode/people/forms/recaptcha.py
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2019 Open Source Geospatial Foundation - all rights reserved
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+#########################################################################
+from django import forms
+from allauth.account.forms import LoginForm
+
+try:
+ from captcha.fields import ReCaptchaField
+except ImportError:
+ from django_recaptcha.fields import ReCaptchaField
+
+
+class AllauthReCaptchaSignupForm(forms.Form):
+ captcha = ReCaptchaField(label=False)
+
+ def signup(self, request, user):
+ """Required, or else it thorws deprecation warnings"""
+ pass
+
+
+class AllauthRecaptchaLoginForm(LoginForm):
+ captcha = ReCaptchaField(label=False)
+
+ def login(self, *args, **kwargs):
+ return super(AllauthRecaptchaLoginForm, self).login(*args, **kwargs)
diff --git a/geonode/people/templates/people/account_login.html b/geonode/people/templates/people/account_login.html
new file mode 100644
index 00000000000..b37273684f4
--- /dev/null
+++ b/geonode/people/templates/people/account_login.html
@@ -0,0 +1,14 @@
+{% extends "account/login.html" %}
+{% comment %} Inherited from Django AllAuth default login form {% endcomment %}
+
+{% block extra_script %}
+
+{% endblock extra_script %}
diff --git a/geonode/people/views.py b/geonode/people/views.py
index 3abfae18fcf..bf9e8f4cf8f 100644
--- a/geonode/people/views.py
+++ b/geonode/people/views.py
@@ -16,7 +16,7 @@
# along with this program. If not, see .
#
#########################################################################
-from allauth.account.views import SignupView
+from allauth.account.views import SignupView, LoginView
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from django.contrib import messages
@@ -57,6 +57,10 @@ def get_context_data(self, **kwargs):
return ret
+class CustomLoginView(LoginView):
+ template_name = "people/account_login.html"
+
+
@login_required
def profile_edit(request, username=None):
if username is None:
diff --git a/geonode/settings.py b/geonode/settings.py
index 17532826c7d..8e31414e304 100644
--- a/geonode/settings.py
+++ b/geonode/settings.py
@@ -1399,8 +1399,11 @@
if "django_recaptcha" not in INSTALLED_APPS:
INSTALLED_APPS += ("django_recaptcha",)
ACCOUNT_SIGNUP_FORM_CLASS = os.getenv(
- "ACCOUNT_SIGNUP_FORM_CLASS", "geonode.people.forms.AllauthReCaptchaSignupForm"
+ "ACCOUNT_SIGNUP_FORM_CLASS", "geonode.people.forms.recaptcha.AllauthReCaptchaSignupForm"
)
+
+ # https://docs.allauth.org/en/dev/account/configuration.html
+ ACCOUNT_FORMS = dict(login="geonode.people.forms.recaptcha.AllauthRecaptchaLoginForm")
"""
In order to generate reCaptcha keys, please see:
- https://pypi.org/project/django-recaptcha/#installation
diff --git a/geonode/urls.py b/geonode/urls.py
index 87d489d4edd..20b93d08d21 100644
--- a/geonode/urls.py
+++ b/geonode/urls.py
@@ -43,7 +43,7 @@
from geonode.utils import check_ogc_backend
from geonode.base import register_url_event
from geonode.messaging.urls import urlpatterns as msg_urls
-from .people.views import CustomSignupView
+from .people.views import CustomSignupView, CustomLoginView
from oauth2_provider.urls import app_name as oauth2_app_name, base_urlpatterns, oidc_urlpatterns
admin.autodiscover()
@@ -93,6 +93,7 @@
re_path(r"^h_keywords_api$", views.h_keywords, name="h_keywords_api"),
# Social views
re_path(r"^account/signup/", CustomSignupView.as_view(), name="account_signup"),
+ re_path(r"^account/login/", CustomLoginView.as_view(), name="account_login"),
re_path(r"^account/", include("allauth.urls")),
re_path(r"^invitations/", include("geonode.invitations.urls", namespace="geonode.invitations")),
re_path(r"^people/", include("geonode.people.urls")),