Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6dea941

Browse files
authored
Fix bug with social account adapter name override, in very specific conditions (cookiecutter#4650)
* Fix bug with social account adapter in specific condition * Slight refactoring of fix
1 parent befc571 commit 6dea941

File tree

1 file changed

+9
-8
lines changed
  • {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users

1 file changed

+9
-8
lines changed

‎{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/adapters.py‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ def populate_user(self, request: HttpRequest, sociallogin: SocialLogin, data: di
2727
2828
See: https://django-allauth.readthedocs.io/en/latest/advanced.html?#creating-and-populating-user-instances
2929
"""
30-
user = sociallogin.user
31-
if name := data.get("name"):
32-
user.name = name
33-
elif first_name := data.get("first_name"):
34-
user.name = first_name
35-
if last_name := data.get("last_name"):
36-
user.name += f" {last_name}"
37-
return super().populate_user(request, sociallogin, data)
30+
user = super().populate_user(request, sociallogin, data)
31+
if not user.name:
32+
if name := data.get("name"):
33+
user.name = name
34+
elif first_name := data.get("first_name"):
35+
user.name = first_name
36+
if last_name := data.get("last_name"):
37+
user.name += f" {last_name}"
38+
return user

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /