Link social login to existing email principal#47
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
FindOrCreateWithPolicyto link a social identity to an existing principal wheninfo.Emailmatches 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.