Skip to content

Commit

Permalink
Set username to fall back to email address
Browse files Browse the repository at this point in the history
  • Loading branch information
smcgu committed Jan 30, 2025
1 parent ff19edf commit 4984f63
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ghostwriter/users/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ def populate_user(self, request, sociallogin, data):
last_name = data.get("last_name")
email = data.get("email")
name = data.get("name")

# If no username or the username is the email address
# Use the email address but strip the domain
if username is None or (username == email):
username = email.split("@")[0]

user = sociallogin.user
user_username(user, username or "")
user_email(user, valid_email_or_none(email) or "")

# If the username is the email address, strip the domain
if username == email:
user_username(user, username.split("@")[0])

name_parts = (name or "").partition(" ")
user_field(user, "first_name", first_name or name_parts[0])
user_field(user, "last_name", last_name or name_parts[2])
Expand Down

0 comments on commit 4984f63

Please sign in to comment.