Skip to content

fix(auth): save user name on Google sign-in#98

Merged
miquelmatoses merged 1 commit into
mainfrom
fix/google-oauth-save-name
Jun 17, 2026
Merged

fix(auth): save user name on Google sign-in#98
miquelmatoses merged 1 commit into
mainfrom
fix/google-oauth-save-name

Conversation

@miquelmatoses

Copy link
Copy Markdown
Collaborator

Problem

Registering with Google did not persist the user's name. google_callback (api/auth.py) only read id and email from the Google userinfo response and discarded given_name / family_name. _find_or_create_user then inserted the profile with only id + email, so profiles.first_name / profiles.last_name stayed NULL.

Fix

  • Extract given_name / family_name in google_callback and pass them through _find_or_create_user.
  • Write them to the existing profiles.first_name / profiles.last_name columns (Phase 10.18 — no migration needed).
  • Upsert uses COALESCE(profiles.<col>, EXCLUDED.<col>) so the name is only set when empty: a later Google login never overwrites a name the user edited. Empty incoming values normalise to NULL.

Names live on profiles (where every reader looks via first_name/last_name), not auth_users.

Tests

New api/tests/test_auth_google_name.py (fake-conn pattern from test_events.py): name reaches the profiles upsert; empty/whitespace names become NULL; no-name callers default to NULL; asserts the COALESCE guard is present. Full backend suite green (164 passed).

🤖 Generated with Claude Code

Google's oauth2/v2/userinfo returns given_name / family_name when the
profile scope is granted, but google_callback only read id and email, so
a Google sign-up never stored a name. Extract given_name/family_name in
the callback and pass them to _find_or_create_user, which writes them to
profiles.first_name / profiles.last_name (the existing Phase 10.18 name
columns; no migration needed).

The profiles upsert uses COALESCE(profiles.<col>, EXCLUDED.<col>) so the
name is only set when currently empty: a name the user later edits is
never overwritten by a subsequent Google login. Empty incoming values are
normalised to NULL.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@miquelmatoses miquelmatoses merged commit f5eda46 into main Jun 17, 2026
7 checks passed
@miquelmatoses miquelmatoses deleted the fix/google-oauth-save-name branch June 17, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant