Fix bug with social account adapter name override, in very specific conditions (#4650)

* Fix bug with social account adapter in specific condition

* Slight refactoring of fix
This commit is contained in:
Christian Jauvin 2023-11-20 07:45:20 -05:00 committed by GitHub
parent befc571342
commit 6dea941258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,11 +27,12 @@ class SocialAccountAdapter(DefaultSocialAccountAdapter):
See: https://django-allauth.readthedocs.io/en/latest/advanced.html?#creating-and-populating-user-instances
"""
user = sociallogin.user
if name := data.get("name"):
user.name = name
elif first_name := data.get("first_name"):
user.name = first_name
if last_name := data.get("last_name"):
user.name += f" {last_name}"
return super().populate_user(request, sociallogin, data)
user = super().populate_user(request, sociallogin, data)
if not user.name:
if name := data.get("name"):
user.name = name
elif first_name := data.get("first_name"):
user.name = first_name
if last_name := data.get("last_name"):
user.name += f" {last_name}"
return user