From 296cdc53ee41bb58d0fe5c56df6fc1f7100dd7d4 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Tue, 13 Aug 2019 10:53:38 -0600 Subject: [PATCH] FIX: Downcase email coming back from auth-provider --- lib/auth/result.rb | 4 ++++ spec/components/auth/managed_authenticator_spec.rb | 5 +++++ 2 files changed, 9 insertions(+) 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: "HELLO@example.com" })) + expect(result.email).to eq('hello@example.com') + end + it 'works normally' do user = Fabricate(:user) result = authenticator.after_authenticate(hash.deep_merge(info: { email: user.email }))