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
This commit is contained in:
Sam Saffron 2019-05-13 16:45:24 +10:00
parent d369b84ced
commit 3fbab595d9
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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)