From 0278e80f165d299279c98bafad2c4185b066712c Mon Sep 17 00:00:00 2001 From: Jered Floyd Date: Wed, 6 Dec 2023 22:26:33 +0000 Subject: [PATCH] Allow new sociallogin accounts to establish SITE_ID from request --- allauth/socialaccount/helpers.py | 2 +- allauth/socialaccount/models.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/allauth/socialaccount/helpers.py b/allauth/socialaccount/helpers.py index eec6233270..dcb7dbee9f 100644 --- a/allauth/socialaccount/helpers.py +++ b/allauth/socialaccount/helpers.py @@ -205,7 +205,7 @@ def _add_social_account(request, sociallogin): def complete_social_login(request, sociallogin): assert not sociallogin.is_existing - sociallogin.lookup() + sociallogin.lookup(request) try: get_adapter().pre_social_login(request, sociallogin) signals.pre_social_login.send( diff --git a/allauth/socialaccount/models.py b/allauth/socialaccount/models.py index 13c53bd98f..bf68ff0d50 100644 --- a/allauth/socialaccount/models.py +++ b/allauth/socialaccount/models.py @@ -274,12 +274,12 @@ def is_existing(self): return False return get_user_model().objects.filter(pk=self.user.pk).exists() - def lookup(self): + def lookup(self, request=None): """Look up the existing local user account to which this social login points, if any. """ if not self._lookup_by_socialaccount(): - provider_id = self.account.get_provider().id + provider_id = self.account.get_provider(request).id if app_settings.EMAIL_AUTHENTICATION or app_settings.PROVIDERS.get( provider_id, {} ).get("EMAIL_AUTHENTICATION", False):