Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(socialaccount): Allow account connections page to establish SITE_ID from request #3554

Closed

Conversation

jeredfloyd
Copy link
Contributor

Similar to the fix in #3548 , the subprovider refactoring in 0.55 created the necessity to identity SITE_ID based on the request in get_provider_account, which is used in the Django template for the Account Connections page.

@coveralls
Copy link

Coverage Status

coverage: 95.785%. remained the same
when pulling d55eb5e on jeredfloyd:fix-site-id-connections-2
into 1f8c59d on pennersr:main.

@@ -144,7 +144,7 @@ def get_provider(self, request=None):
return provider

def get_provider_account(self):
return self.get_provider().wrap_account(self)
return self.get_provider(context.request).wrap_account(self)
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, here we are accessing a model stored in the database. And, we should be able to do so even beyond the context of a request. So, when looking up the actual provider/app further down the line, it is actually wrong to try and limit the available apps by those active on the site.

Can you try if this solves your issue instead?:

diff --git a/allauth/socialaccount/adapter.py b/allauth/socialaccount/adapter.py
index 902c5782..a56ba482 100644
--- a/allauth/socialaccount/adapter.py
+++ b/allauth/socialaccount/adapter.py
@@ -228,7 +228,10 @@ class DefaultSocialAccountAdapter(object):
         provider_to_apps = {}
 
         # First, populate it with the DB backed apps.
-        db_apps = SocialApp.objects.on_site(request)
+        if request:
+            db_apps = SocialApp.objects.on_site(request)
+        else:
+            db_apps = SocialApp.objects.all()
         if provider:
             db_apps = db_apps.filter(Q(provider=provider) | Q(provider_id=provider))
         if client_id:

... and, if so, does this address the previous issue as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! Your proposed change resolves both issues.

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, thanks for confirming. Will apply this and revert the other change.

Copy link
Owner

Choose a reason for hiding this comment

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

@pennersr
Copy link
Owner

pennersr commented Dec 7, 2023

Closed via e5c480c

@pennersr pennersr closed this Dec 7, 2023
@jeredfloyd jeredfloyd deleted the fix-site-id-connections-2 branch December 7, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants