[PR #7108] [CLOSED] fix: normalize email to lowercase in handleOAuthUserInfo #7081

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7108
Author: @rushil-b-patel
Created: 1/3/2026
Status: Closed

Base: canaryHead: fix/acsEndpoint-uses-case-sensitive-email


📝 Commits (1)

  • f8d7cfc fix: normalize email to lowercase in handleOAuthUserInfo

📊 Changes

1 file changed (+11 additions, -12 deletions)

View changed files

📝 packages/better-auth/src/oauth2/link-account.ts (+11 -12)

📄 Description

Closes issue:7052

Fixes case-sensitivity issue where SAML/OAuth SSO logins failed when IdPs (like Okta) sent mixed-case emails after user was created with lowercase email.

Key Changes:

  • Normalize userInfo.email to lowercase at entry point of handleOAuthUserInfo
  • Remove redundant .toLowerCase() calls throughout the function

Summary by cubic

Normalize incoming SSO email to lowercase at the start of handleOAuthUserInfo to make email matching case-insensitive and prevent login failures with mixed-case emails. Consolidates lowercasing to one place and uses the normalized email for lookups and updates.

  • Bug Fixes
    • Lowercase userInfo.email once at the entry point.
    • Use the normalized email in findOAuthUser and emailVerified checks.
    • Pass the normalized email to update/create user calls.
    • Remove redundant .toLowerCase() calls throughout the function.

Written for commit f8d7cfcaa2. 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/7108 **Author:** [@rushil-b-patel](https://github.com/rushil-b-patel) **Created:** 1/3/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/acsEndpoint-uses-case-sensitive-email` --- ### 📝 Commits (1) - [`f8d7cfc`](https://github.com/better-auth/better-auth/commit/f8d7cfcaa22d9d8773a1a85582893b25809034c6) fix: normalize email to lowercase in handleOAuthUserInfo ### 📊 Changes **1 file changed** (+11 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/oauth2/link-account.ts` (+11 -12) </details> ### 📄 Description Closes [issue:7052](https://github.com/better-auth/better-auth/issues/7052) Fixes case-sensitivity issue where SAML/OAuth SSO logins failed when IdPs (like Okta) sent mixed-case emails after user was created with lowercase email. Key Changes: - Normalize `userInfo.email` to lowercase at entry point of `handleOAuthUserInfo` - Remove redundant `.toLowerCase()` calls throughout the function <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Normalize incoming SSO email to lowercase at the start of handleOAuthUserInfo to make email matching case-insensitive and prevent login failures with mixed-case emails. Consolidates lowercasing to one place and uses the normalized email for lookups and updates. - **Bug Fixes** - Lowercase userInfo.email once at the entry point. - Use the normalized email in findOAuthUser and emailVerified checks. - Pass the normalized email to update/create user calls. - Remove redundant .toLowerCase() calls throughout the function. <sup>Written for commit f8d7cfcaa22d9d8773a1a85582893b25809034c6. 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:23:23 -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#7081