Fixing bug with Google emails containing capital letters (SCP-6061) #2319
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.
BACKGROUND & CHANGES
This fixes a long-standing bug with some users not being able to sign back into SCP after initially creating an account. The problem lies with Devise (our main auth handler) and the fact that these users have capitalization in their emails according to their Google profiles. Since all modern email providers do not recognize capitalization, this is not normally an issue, but SCP has custom handling to decode the email from their profile and then do a lookup based on that value. If there are capital letters, the query fails. This leads to SCP trying to create a new user account (which is what happens the first time anyone logs in). This always works the first time and will fail every time after because the email address is taken, but the query will never find the correct account. This explains the infinite loop because we redirect back to the sign in page as the user hasn't successfully signed into SCP. Now, the account lookup correctly uses the downcased email, as this is what is saved by Devise.
MANUAL TESTING
If you do not have access to an email account with capitalization of the email in the Google profile, it is not possible to test this manually. The new UserTest
should correctly find user if profile has capital letterscovers this sufficiently. You can prove that it works by doing the following:app/models/user.rbback to the original: