fix: normalize oauth emails before matching users#9488
Open
tristanbob wants to merge 1 commit intocoollabsio:nextfrom
Open
fix: normalize oauth emails before matching users#9488tristanbob wants to merge 1 commit intocoollabsio:nextfrom
tristanbob wants to merge 1 commit intocoollabsio:nextfrom
Conversation
Contributor
|
Nice catch and fix @tristanbob for the mixed-case lookup issue. There's one huge edge case that needs to be looked at though, if a provider returns no email, That means we could end up querying Can you add an explicit non-empty email check before normalizing plus a small regression test for TLDR: One huge edge case: casting My suggested fix is... $oauthUser = get_socialite_provider($provider)->user();
$email = trim((string) $oauthUser->email);
if ($email === '') {
abort(403, 'OAuth provider did not return an email address');
}
$email = strtolower($email);
$user = User::whereEmail($email)->first();
if (! $user) {
$settings = instanceSettings();
if (! $settings->is_registration_enabled) {
abort(403, 'Registration is disabled');
}
$user = User::create([
'name' => $oauthUser->name,
'email' => $email,
]);
} |
Iisyourdad
reviewed
Apr 9, 2026
9a23706 to
519a186
Compare
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
(This is Tristan, a human, and have review this PR for accuracy)
Issues
Category
Preview
N/A. This is a backend auth bug fix with no UI change.
AI Assistance
If AI was used:
Testing
php artisan test --compact tests/Feature/OauthControllerTest.phpvendor/bin/pint --dirty --format agentContributor Agreement
Important