fix: override user info on GitHub sign-in to self-heal stale-emailed accounts - #61
Conversation
Status update: existing duplicates are fixed in production; this PR is now preventativeThe five existing affected users have been repaired directly in the planner's production database today — a merge of their duplicate members into their real accounts. Each merge:
Verified post-apply: no duplicate members remain and no orphaned references to the deleted rows. A side note surfaced during the cleanup: the local Because the merges move each user's That makes this change preventative rather than remedial:
Still worth shipping, but it is hardening — it is not what unblocks the current five. |
Problem
PR #60 (merge
e9ffa8f) resolved the duplicate-signup bug for new GitHub sign-ups by picking the primary + verified email from/user/emails. But it does nothing for users who already linked their GitHub account to the auth app before that shipped. Better Auth matches returning GitHub logins on the numeric GitHub account ID and reuses the user's stored email (e.g. the old public-profile address), so affected users stay bound to a duplicate planner account.Fix
Set
overrideUserInfoOnSignIn: trueon the GitHub provider. Better Auth then overwrites the stored email with the freshly-resolved primary on every sign-in (including pre-linked accounts), so affected users self-heal to their primary email on their next login, with no manual data entry.Verification
test/unit/github-provider.test.jsgreen (github-provider.js 100% stmts / 92.85% branch).