Skip to content

Link social login to existing email principal#47

Merged
noctarius merged 2 commits into
mainfrom
fix-social-account-linking
Apr 24, 2026
Merged

Link social login to existing email principal#47
noctarius merged 2 commits into
mainfrom
fix-social-account-linking

Conversation

@noctarius
Copy link
Copy Markdown
Collaborator

Fix social identity linking to reuse an existing principal when the provider email matches an existing principal slug. This prevents duplicate user records during Google sign-in for already provisioned accounts.

Add an integration regression test that reproduces the duplicate-account case and verifies only one principal remains while the social identity is linked. Update the slug-collision test to continue covering non-email fallback slug collision behavior.

Fix social identity linking to reuse an existing principal when the
provider email matches an existing principal slug. This prevents duplicate
user records during Google sign-in for already provisioned accounts.

Add an integration regression test that reproduces the duplicate-account
case and verifies only one principal remains while the social identity is
linked. Update the slug-collision test to continue covering non-email
fallback slug collision behavior.

Co-authored-by: Codex <noreply@openai.com>
@noctarius noctarius self-assigned this Apr 24, 2026
Copilot AI review requested due to automatic review settings April 24, 2026 11:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes social identity linking so that when a social provider returns an email matching an existing principal slug, the existing principal is reused (avoiding duplicate user principals). It also adds an integration regression test to cover the duplicate-account scenario and updates existing collision coverage.

Changes:

  • Updated FindOrCreateWithPolicy to link a social identity to an existing principal when info.Email matches a principal slug.
  • Added an integration regression test ensuring only one principal exists and the social identity links to it.
  • Adjusted slug-collision integration test to focus on non-email slug collision behavior; documented the change in designs/TASKS.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/social/identity.go Changes identity resolution flow to reuse an existing principal by email slug before auto-creating a new principal.
internal/social/identity_test.go Adds regression coverage for existing-email slug linking; updates slug-collision coverage to use non-email base slugs.
designs/TASKS.md Records the implementation task and the behavioral intent of the fix/tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/social/identity.go
Comment thread internal/social/identity.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@noctarius noctarius merged commit 5920b73 into main Apr 24, 2026
15 checks passed
@noctarius noctarius deleted the fix-social-account-linking branch April 24, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants