Skip to content

Commit

Permalink
Add custom login view/template to support recaptcha on Login Form
Browse files Browse the repository at this point in the history
  • Loading branch information
cmotadev committed Jan 21, 2025
1 parent 734d1e8 commit 6af3cac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions geonode/people/forms/recaptcha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#
# Copyright (C) 2019 Open Source Geospatial Foundation - all rights reserved
#
Expand Down Expand Up @@ -27,7 +26,7 @@

class AllauthReCaptchaSignupForm(forms.Form):
captcha = ReCaptchaField(label=False)

Check warning on line 28 in geonode/people/forms/recaptcha.py

View check run for this annotation

Codecov / codecov/patch

geonode/people/forms/recaptcha.py#L27-L28

Added lines #L27 - L28 were not covered by tests

def signup(self, request, user):

Check warning on line 30 in geonode/people/forms/recaptcha.py

View check run for this annotation

Codecov / codecov/patch

geonode/people/forms/recaptcha.py#L30

Added line #L30 was not covered by tests
"""Required, or else it thorws deprecation warnings"""
pass

Check warning on line 32 in geonode/people/forms/recaptcha.py

View check run for this annotation

Codecov / codecov/patch

geonode/people/forms/recaptcha.py#L32

Added line #L32 was not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions geonode/people/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def get_context_data(self, **kwargs):
form = ret["form"]
form.field_order = [f for f in form.fields.keys() if f != "captcha"] + ["captcha"]
form.order_fields(form.field_order)
return ret
return ret


class CustomLoginView(LoginView):
template_name = 'people/account_login.html'
template_name = "people/account_login.html"


@login_required
Expand Down
5 changes: 1 addition & 4 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,10 +1403,7 @@
)

# https://docs.allauth.org/en/dev/account/configuration.html
ACCOUNT_FORMS = dict(
login='geonode.people.forms.recaptcha.AllauthRecaptchaLoginForm'
)

ACCOUNT_FORMS = dict(login="geonode.people.forms.recaptcha.AllauthRecaptchaLoginForm")

Check warning on line 1406 in geonode/settings.py

View check run for this annotation

Codecov / codecov/patch

geonode/settings.py#L1406

Added line #L1406 was not covered by tests
"""
In order to generate reCaptcha keys, please see:
- https://pypi.org/project/django-recaptcha/#installation
Expand Down

0 comments on commit 6af3cac

Please sign in to comment.