Skip to content

A platform for community discussion. Free, open, simple.

FIX: Downcase email coming back from auth-provider

Blake Erickson296cdc53ee41
diff --git a/lib/auth/result.rb b/lib/auth/result.rb
index 8ad478c2921..d825758433f 100644
--- a/lib/auth/result.rb
+++ b/lib/auth/result.rb
@@ -18,6 +18,10 @@ class Auth::Result
@failed = false
end
+ def email
+ @email.downcase
+ end
+
def failed?
!!@failed
end
diff --git a/spec/components/auth/managed_authenticator_spec.rb b/spec/components/auth/managed_authenticator_spec.rb
index ba463ed44e4..84889de712f 100644
--- a/spec/components/auth/managed_authenticator_spec.rb
+++ b/spec/components/auth/managed_authenticator_spec.rb
@@ -90,6 +90,11 @@ describe Auth::ManagedAuthenticator do
end
describe 'match by email' do
+ it 'downcases the email address from the authprovider' do
+ result = authenticator.after_authenticate(hash.deep_merge(info: { email: "[email protected]" }))
+ expect(result.email).to eq('[email protected]')
+ end
+
it 'works normally' do
user = Fabricate(:user)
result = authenticator.after_authenticate(hash.deep_merge(info: { email: user.email }))