Fix: handle allauth groups location breaking change (#11471)

This commit is contained in:
shamoon
2025-11-25 09:18:05 -08:00
committed by GitHub
parent a76731ca89
commit 1e61a6cd6a
2 changed files with 73 additions and 2 deletions

View File

@@ -38,10 +38,19 @@ def handle_social_account_updated(sender, request, sociallogin, **kwargs):
"""
from django.contrib.auth.models import Group
social_account_groups = sociallogin.account.extra_data.get(
extra_data = sociallogin.account.extra_data or {}
social_account_groups = extra_data.get(
"groups",
[],
) # None if not found
) # pre-allauth 65.11.0 structure
if not social_account_groups:
# allauth 65.11.0+ nests claims under `userinfo`/`id_token`
social_account_groups = (
extra_data.get("userinfo", {}).get("groups")
or extra_data.get("id_token", {}).get("groups")
or []
)
if settings.SOCIAL_ACCOUNT_SYNC_GROUPS and social_account_groups is not None:
groups = Group.objects.filter(name__in=social_account_groups)
logger.debug(