Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions social_core/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# already part of the auth response from the provider, but sometimes this
# could hit a provider API.
"social_core.pipeline.social_auth.social_details",
# Populate first+last name from full name and vice-versa, if needed
"social_core.pipeline.social_auth.social_names",
# Get the social uid from whichever service we're authing thru. The uid is
# the unique identifier of the given user in the provider.
"social_core.pipeline.social_auth.social_uid",
Expand Down
15 changes: 15 additions & 0 deletions social_core/pipeline/social_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
return {"details": dict(backend.get_user_details(response), **details)}


def social_names(backend, details, response, *args, **kwargs):
# If first+last are both missing, populate from full
if details.get("fullname") and backend.setting("FIRSTLAST_FROM_FULL", True):
if not (details.get("first_name") or details.get("last_name")):

Check failure on line 11 in social_core/pipeline/social_auth.py

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Ruff (SIM102)

social_core/pipeline/social_auth.py:10:5: SIM102 Use a single `if` statement instead of nested `if` statements
first, _space, last = details["fullname"].rpartition(" ")
details["first_name"] = first.strip()
details["last_name"] = last.strip()
print(f"end social_names {details=}")

Check failure on line 15 in social_core/pipeline/social_auth.py

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Ruff (T201)

social_core/pipeline/social_auth.py:15:13: T201 `print` found

Check warning on line 15 in social_core/pipeline/social_auth.py

View check run for this annotation

Codecov / codecov/patch

social_core/pipeline/social_auth.py#L12-L15

Added lines #L12 - L15 were not covered by tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I'll need to remove this, but I'd like to confirm that the general direction seems good before I do the cleanup.)


# If first+last are both present, populate full if that's missing
if not details.get("fullname") and backend.setting("FULL_FROM_FIRSTLAST", True):
if details.get("first_name") and details.get("last_name"):

Check failure on line 19 in social_core/pipeline/social_auth.py

View workflow job for this annotation

GitHub Actions / pre-commit / pre-commit

Ruff (SIM102)

social_core/pipeline/social_auth.py:18:5: SIM102 Use a single `if` statement instead of nested `if` statements
details["fullname"] = details["first_name"] + " " + details["last_name"]

Check warning on line 20 in social_core/pipeline/social_auth.py

View check run for this annotation

Codecov / codecov/patch

social_core/pipeline/social_auth.py#L20

Added line #L20 was not covered by tests


def social_uid(backend, details, response, *args, **kwargs):
return {"uid": str(backend.get_user_id(details, response))}

Expand Down
Loading