Support case-insensitive username logins #14585
Open
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.
Fixes #14586. See issue for more product details.
Changes
Previously, the login controller was searching the DB for a record with an exact case-sensitive username match (returning either a
Document
orundefined
).This PR makes the login controller search the DB for all records with a case-insensitive username match (returning a
Document[]
). If the resulting array's size is 0,user = undefined
. If the size is 1,user = result[0]
. If the size is 2+, we search the resultingDocument[]
for an exact case-sensitive username match, returning either aDocument
orundefined
.Demo
Click the header link for a full video of creating the users if you want a fuller picture
Disclaimer
I've manually tested that users with colliding usernames still log with the same case-sensitive behavior by removing the unique username constraint on my local instance's registration controller (demonstrated in this video), but I don't believe it's possible to add this case to the integration tests because we can't/shouldn't lift that constraint on the actual registration controller.
UUID: 99f20106-7060-4398-b565-26e56c4de2ad