Closed Wesley257 closed 1 year ago
Take a look at: https://stackoverflow.com/questions/13991604/mongoose-schema-validating-unique-field-case-insensitive, implement the second answer. Emails should still be stored as they are now, but its index should be updated to be case insensitive. You will likely need to change the query to specify the collation to match the index (see https://www.mongodb.com/docs/manual/core/index-case-insensitive/#create-a-case-insensitive-index).
Description
Emails are not case sensitive, so how they are stored/used/input in our database should also be NOT case sensitive (in other words they should be case INsensitive). Whenever emails are used or checked for existence in our database, make sure they are all being converted to lowercase before these checks occur. Users may prefer to see their email a certain way though (with capitals in some places), so when it is displayed on the profile, it should still be displayed however it was input.
fakeemail@gmail.com == FakeEmail@gmail.com == FAKEEMAIL@gmail.com
Since this is a database change, please test that it still works when you input any new email with upper and lower cased emails and the same results happens.