fix: user.socialaccount might be None#901
Conversation
When self hosting, an `org_member` might not have a `socialaccount` set.
|
Thanks for catching this! The When users sign up with email + password, https://github.com/phasehq/console/blob/main/backend/api/models.py#L55 So with the current patch, password-signup users get their email address in the invite mail ("Alice (alice@acme.com) invited you...") even though we know they're Alice. The login email flow already handles this correctly — it falls back from social https://github.com/phasehq/console/blob/main/backend/api/views/auth_password.py#L402-L415 Could we mirror that resolution chain in def get_org_member_name(org_member):
user = org_member.user
social_acc = user.socialaccount_set.first()
if social_acc:
name = (social_acc.extra_data or {}).get("name")
if name:
return name
if user.full_name:
return user.full_name
return user.emailThis keeps the SSO behaviour identical, fixes the |
|
Hi, thank you for your review :) You are right, |
Great! I'll give it a quick check myself and get this merged so we can add it to next release. |
When self hosting phase with just simple password authentication inviting new members per email does not work, because the org member does not have a social account set.
The missing check caused the following error:
Just checking whether
social_accisNoneinget_org_member_nameshould be enough of a fix without major refactoring. imho an issue for this small change was not needed.I have searched the codebase for other places, where
socialaccount_setis not being checked, but this was the only place.