FEATURE: use the exact name provided by auth provider

FEATURE: use the exact name provided by auth provider

Previously we would attempt to titleize it causing names like McDonald’s not to work as expected

diff --git a/lib/auth/result.rb b/lib/auth/result.rb
index 7b9f9f8..fc93940 100644
--- a/lib/auth/result.rb
+++ b/lib/auth/result.rb
@@ -73,7 +73,7 @@ class Auth::Result
       result[:destination_url] = destination_url if destination_url.present?
 
       if SiteSetting.enable_names?
-        result[:name] = User.suggest_name(name || username || email)
+        result[:name] = name.presence || User.suggest_name(username || email)
       end
 
       result
diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rb
index cdb3660..d830d99 100644
--- a/spec/requests/omniauth_callbacks_controller_spec.rb
+++ b/spec/requests/omniauth_callbacks_controller_spec.rb
@@ -1,6 +1,7 @@
 # frozen_string_literal: true
 
 require 'rails_helper'
+require 'single_sign_on'
 
 RSpec.describe Users::OmniauthCallbacksController do
   fab!(:user) { Fabricate(:user) }
@@ -98,16 +99,16 @@ RSpec.describe Users::OmniauthCallbacksController do
           uid: '123545',
           info: OmniAuth::AuthHash::InfoHash.new(
             email: email,
-            name: 'Some name',
+            name: 'Some Name',
             first_name: "Some",
-            last_name: "name"
+            last_name: "Name"
           ),
           extra: {
             raw_info: OmniAuth::AuthHash.new(
               email_verified: true,
               email: email,
               family_name: 'Huh',
-              given_name: "Some name",
+              given_name: "Some Name",
               gender: 'male',
               name: "Some name Huh",
             )
@@ -128,7 +129,7 @@ RSpec.describe Users::OmniauthCallbacksController do
         response_body = JSON.parse(response.body)
 
         expect(response_body["email"]).to eq(email)
-        expect(response_body["username"]).to eq("Some_name")
+        expect(response_body["username"]).to eq("Some_Name")
         expect(response_body["auth_provider"]).to eq("google_oauth2")
         expect(response_body["email_valid"]).to eq(true)
         expect(response_body["omit_username"]).to eq(false)

GitHub sha: 3fbab595

This commit has been mentioned on Discourse Meta. There might be relevant details there: