Skip to content

Commit

Permalink
fix(socialaccount): Fetch settings from main provider
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Sep 22, 2023
1 parent 24049ad commit be779df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion allauth/socialaccount/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ def lookup(self):
points, if any.
"""
if not self._lookup_by_socialaccount():
provider_id = self.account.get_provider().id
if app_settings.EMAIL_AUTHENTICATION or app_settings.PROVIDERS.get(
self.account.provider, {}
provider_id, {}
).get("EMAIL_AUTHENTICATION", False):
self._lookup_by_email()

Expand Down
10 changes: 8 additions & 2 deletions allauth/socialaccount/tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
from unittest.mock import patch

from django.contrib.auth.models import AnonymousUser
Expand Down Expand Up @@ -37,14 +38,19 @@ def test_email_authentication(
if setting == "on-global":
settings.SOCIALACCOUNT_EMAIL_AUTHENTICATION = True
elif setting == "on-provider":
settings.SOCIALACCOUNT_PROVIDERS["google"] = {"EMAIL_AUTHENTICATION": True}
settings.SOCIALACCOUNT_PROVIDERS = copy.deepcopy(
settings.SOCIALACCOUNT_PROVIDERS
)
settings.SOCIALACCOUNT_PROVIDERS["openid_connect"][
"EMAIL_AUTHENTICATION"
] = True
else:
settings.SOCIALACCOUNT_EMAIL_AUTHENTICATION = False
settings.SOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT = auto_connect

user = user_factory()

sociallogin = sociallogin_factory(email=user.email, provider="google")
sociallogin = sociallogin_factory(email=user.email, provider="unittest-server")

request = rf.get("/")
SessionMiddleware(lambda request: None).process_request(request)
Expand Down

0 comments on commit be779df

Please sign in to comment.