[PR #7812] [MERGED] fix(oauth): support case-insensitive email matching for social account linking #7568

Closed
opened 2026-03-13 13:41:44 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7812
Author: @karuppusamy-d
Created: 2/5/2026
Status: Merged
Merged: 2/12/2026
Merged by: @himself65

Base: canaryHead: fix/case-insensitive-email-linking


📝 Commits (2)

  • bc46949 fix(oauth): support case-insensitive email matching for social account linking
  • 199d420 fix: ensure case-insensitive email matching for account linking

📊 Changes

4 files changed (+179 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/api/routes/account.ts (+2 -1)
📝 packages/better-auth/src/api/routes/callback.ts (+1 -1)
📝 packages/better-auth/src/oauth2/link-account.test.ts (+175 -0)
📝 packages/better-auth/src/plugins/generic-oauth/routes.ts (+1 -1)

📄 Description

This ensures that social account linking succeeds even if the email
returned by the OAuth provider has different casing than the email
currently associated with the user.

  • Update linkSocialAccount and callbackOAuth to use case-insensitive email comparison.
  • Added comprehensive tests for both callback and idToken flows.
  • Prevents "email_doesn't_match" errors due to case sensitivity.

Closes #7806


Summary by cubic

Make email comparison case-insensitive during social account linking. This prevents mismatches when OAuth providers return different casing, so linking succeeds instead of showing "email_doesn't_match".

  • Bug Fixes
    • Compare emails case-insensitively in linkSocialAccount, callbackOAuth, and the generic OAuth callback route.
    • Add tests for callback and idToken flows that cover casing differences.

Written for commit 199d42032f. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7812 **Author:** [@karuppusamy-d](https://github.com/karuppusamy-d) **Created:** 2/5/2026 **Status:** ✅ Merged **Merged:** 2/12/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/case-insensitive-email-linking` --- ### 📝 Commits (2) - [`bc46949`](https://github.com/better-auth/better-auth/commit/bc46949c33f793e0433fed7d4c4cafdb1334040e) fix(oauth): support case-insensitive email matching for social account linking - [`199d420`](https://github.com/better-auth/better-auth/commit/199d42032f7b55f142a1e40090d5af99fa4f0562) fix: ensure case-insensitive email matching for account linking ### 📊 Changes **4 files changed** (+179 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/account.ts` (+2 -1) 📝 `packages/better-auth/src/api/routes/callback.ts` (+1 -1) 📝 `packages/better-auth/src/oauth2/link-account.test.ts` (+175 -0) 📝 `packages/better-auth/src/plugins/generic-oauth/routes.ts` (+1 -1) </details> ### 📄 Description This ensures that social account linking succeeds even if the email returned by the OAuth provider has different casing than the email currently associated with the user. - Update `linkSocialAccount` and `callbackOAuth` to use case-insensitive email comparison. - Added comprehensive tests for both callback and idToken flows. - Prevents "email_doesn't_match" errors due to case sensitivity. Closes #7806 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make email comparison case-insensitive during social account linking. This prevents mismatches when OAuth providers return different casing, so linking succeeds instead of showing "email_doesn't_match". - **Bug Fixes** - Compare emails case-insensitively in linkSocialAccount, callbackOAuth, and the generic OAuth callback route. - Add tests for callback and idToken flows that cover casing differences. <sup>Written for commit 199d42032f7b55f142a1e40090d5af99fa4f0562. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:41:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7568