Skip to content

fix(hub): case-insensitive email login#1889

Closed
svenvg93 wants to merge 6 commits intohenrygd:mainfrom
svenvg93:1887-mail-lowercase
Closed

fix(hub): case-insensitive email login#1889
svenvg93 wants to merge 6 commits intohenrygd:mainfrom
svenvg93:1887-mail-lowercase

Conversation

@svenvg93
Copy link
Copy Markdown
Collaborator

@svenvg93 svenvg93 commented Apr 4, 2026

📃 Description

Normalize email addresses to lowercase during login and registration to prevent case-sensitive authentication failures. Users who registered with mixed-case emails (e.g., User@Example.com) could not log in using the lowercase variant (user@example.com).

🪵 Changelog

🔧 Fixed

  • Email login is no longer case-sensitive — addresses are normalized to lowercase on both the frontend (login/register form) and backend (user creation endpoint)

@svenvg93 svenvg93 requested a review from henrygd as a code owner April 4, 2026 10:23
@raudhra
Copy link
Copy Markdown

raudhra commented Apr 6, 2026

What about a user whose mail is user@gmail.com, when you are saving the mail of another user whose mail is User@gmail.com as user@gmail.com

@svenvg93
Copy link
Copy Markdown
Collaborator Author

svenvg93 commented Apr 6, 2026

What about a user whose mail is user@gmail.com, when you are saving the mail of another user whose mail is User@gmail.com as user@gmail.com

By normalizing to lowercase at registration time, two users trying to register user@gmail.com and User@gmail.com will both resolve to user@gmail.com, so the second registration will be rejected as a duplicate. That's exactly the correct behavior.

@raudhra
Copy link
Copy Markdown

raudhra commented Apr 8, 2026

What about a user whose mail is user@gmail.com, when you are saving the mail of another user whose mail is User@gmail.com as user@gmail.com

By normalizing to lowercase at registration time, two users trying to register user@gmail.com and User@gmail.com will both resolve to user@gmail.com, so the second registration will be rejected as a duplicate. That's exactly the correct behavior.

Thank you for explaining senior. Really appreciate the help.

Copy link
Copy Markdown
Owner

@henrygd henrygd left a comment

Choose a reason for hiding this comment

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

Thanks, however I'm worried that converting to lowercase in JS will prevent login if a user's email is already saved with non-lowercase characters.

We would probably need to add a migration that converts all existing emails to lowercase. But this may break oauth logins if the email has non-lowercase on the provider's side.

I found this comment from the PocketBase author that suggests using a collation. Maybe we can add this in a migration.

I'll follow up when I have time to write a few basic tests.

@BootstrapperSBL
Copy link
Copy Markdown
Contributor

Hey @svenvg93 — sorry, I filed #1946 before spotting your PR. Turns out mine takes exactly the COLLATE NOCASE fallback approach @henrygd linked from the PocketBase discussion, so it might be worth looking at for the legacy-mixed-case-accounts concern henrygd raised here. Happy to close #1946 in favour of this one if you want to fold the NOCASE-fallback idea in, or defer to whatever @henrygd prefers.

@svenvg93 svenvg93 closed this Apr 24, 2026
@svenvg93 svenvg93 deleted the 1887-mail-lowercase branch April 24, 2026 07:28
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.

4 participants