Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ GEOSERVER_CORS_ALLOWED_HEADERS=*

# Users Registration
ACCOUNT_OPEN_SIGNUP=True
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_SIGNUP_FIELDS="['email*', 'username*', 'password1*', 'password2*']"
ACCOUNT_APPROVAL_REQUIRED=False
ACCOUNT_CONFIRM_EMAIL_ON_GET=False
ACCOUNT_EMAIL_VERIFICATION=none
ACCOUNT_AUTHENTICATION_METHOD=username_email
ACCOUNT_LOGIN_METHODS="{'email', 'username'}"
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_REGISTERED_MEMBERS_GROUP_NAME=True
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_CONTRIBUTORS=True

Expand Down
4 changes: 2 additions & 2 deletions .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ GEOSERVER_CORS_ALLOWED_HEADERS=*

# Users Registration
ACCOUNT_OPEN_SIGNUP=True
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_SIGNUP_FIELDS="['email*', 'username*', 'password1*', 'password2*']"
ACCOUNT_APPROVAL_REQUIRED=False
ACCOUNT_CONFIRM_EMAIL_ON_GET=False
ACCOUNT_EMAIL_VERIFICATION=none
ACCOUNT_AUTHENTICATION_METHOD=username_email
ACCOUNT_LOGIN_METHODS="{'email', 'username'}"
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_REGISTERED_MEMBERS_GROUP_NAME=True
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_CONTRIBUTORS=True

Expand Down
4 changes: 2 additions & 2 deletions .env_local
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ GEOSERVER_CORS_ALLOWED_HEADERS=*

# Users Registration
ACCOUNT_OPEN_SIGNUP=True
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_SIGNUP_FIELDS="['email*', 'username*', 'password1*', 'password2*']"
ACCOUNT_APPROVAL_REQUIRED=False
ACCOUNT_CONFIRM_EMAIL_ON_GET=False
ACCOUNT_EMAIL_VERIFICATION=none
ACCOUNT_AUTHENTICATION_METHOD=username_email
ACCOUNT_LOGIN_METHODS="{'email', 'username'}"
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_REGISTERED_MEMBERS_GROUP_NAME=True
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_CONTRIBUTORS=True

Expand Down
4 changes: 2 additions & 2 deletions .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ GEOSERVER_CORS_ALLOWED_HEADERS=*

# Users Registration
ACCOUNT_OPEN_SIGNUP=True
ACCOUNT_EMAIL_REQUIRED=True
ACCOUNT_SIGNUP_FIELDS="['email*', 'username*', 'password1*', 'password2*']"
ACCOUNT_APPROVAL_REQUIRED=False
ACCOUNT_CONFIRM_EMAIL_ON_GET=False
ACCOUNT_EMAIL_VERIFICATION=none
ACCOUNT_AUTHENTICATION_METHOD=username_email
ACCOUNT_LOGIN_METHODS="{'email', 'username'}"
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_REGISTERED_MEMBERS_GROUP_NAME=True
AUTO_ASSIGN_REGISTERED_MEMBERS_TO_CONTRIBUTORS=True

Expand Down
21 changes: 19 additions & 2 deletions docs/src/setup/configuration/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,24 @@ It allows specifying the HTTP method used when confirming e-mail addresses.

: - Default ``True``

This is a [django-allauth setting](https://django-allauth.readthedocs.io/en/latest/configuration.html#configuration)
which controls whether the user is required to provide an e-mail address upon registration.
This is deprecated.
Use ``ACCOUNT_SIGNUP_FIELDS`` instead.
It controls whether the user is required to provide an e-mail address upon registration.

**ACCOUNT_EMAIL_VERIFICATION**

: - Default ``optional``

This is a [django-allauth setting](https://django-allauth.readthedocs.io/en/latest/configuration.html#configuration)

**ACCOUNT_LOGIN_METHODS**

: - Default ``{'email', 'username'}``
- Env: ``ACCOUNT_LOGIN_METHODS``

This is a [django-allauth setting](https://docs.allauth.org/en/dev/account/configuration.html)
which controls which identifiers users can use to log in.

**ACCOUNT_LOGIN_REDIRECT_URL**


Expand Down Expand Up @@ -87,6 +96,14 @@ This is a [django-user-accounts setting](https://django-user-accounts.readthedoc
This is a [django-user-accounts setting](https://django-user-accounts.readthedocs.io/en/latest/settings.html)
Whether or not people are allowed to self-register to GeoNode or not.

**ACCOUNT_SIGNUP_FIELDS**

: - Default ``['email*', 'username*', 'password1*', 'password2*']``
- Env: ``ACCOUNT_SIGNUP_FIELDS``

This is a [django-allauth setting](https://docs.allauth.org/en/dev/account/configuration.html)
which controls which fields are shown during signup. Fields marked with ``*`` are required.

**ACCOUNT_SIGNUP_FORM_CLASS**


Expand Down
4 changes: 2 additions & 2 deletions geonode/people/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class GenericOpenIDConnectAdapter(OAuth2Adapter, SocialAccountAdapter):
profile_url = PROFILE_URL
id_token_issuer = ID_TOKEN_ISSUER

def get_provider(self, request=None, provider=None):
def get_provider(self, request=None, provider=None, client_id=None):
"""Looks up a `provider`, supporting subproviders by looking up by
`provider_id`.
"""
Expand All @@ -336,7 +336,7 @@ def get_provider(self, request=None, provider=None):
provider = provider or self.provider_id
provider_class = registry.get_class(provider)
if provider_class is None or provider_class.uses_apps:
app = self.get_app(request, provider=provider)
app = self.get_app(request, provider=provider, client_id=client_id)
if not provider_class:
# In this case, the `provider` argument passed was a
# `provider_id`.
Expand Down
2 changes: 1 addition & 1 deletion geonode/people/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def validate(self, data):
raise serializers.ValidationError(detail="username cannot be updated")
email = data.get("email")
# Email is required on post
if request.method in ("POST") and settings.ACCOUNT_EMAIL_REQUIRED and not email:
if request.method in ("POST") and "email*" in getattr(settings, "ACCOUNT_SIGNUP_FIELDS", []) and not email:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The expression request.method in ("POST") is logically equivalent to request.method in "POST" because ("POST") is a string literal, not a tuple. This could lead to unexpected behavior if request.method were a substring of "POST" (e.g., "P"). It is safer and clearer to use equality or a proper tuple.

Suggested change
if request.method in ("POST") and "email*" in getattr(settings, "ACCOUNT_SIGNUP_FIELDS", []) and not email:
if request.method == "POST" and "email*" in getattr(settings, "ACCOUNT_SIGNUP_FIELDS", []) and not email:

raise serializers.ValidationError(detail="email missing from payload")
# email should be unique
if get_user_model().objects.filter(email=email).exists():
Expand Down
Loading
Loading