Commit 5e907315 authored by Etienne Baqué's avatar Etienne Baqué

Updated code based on reviewer's comments

parent 4cd1e372
...@@ -11,9 +11,6 @@ module Gitlab ...@@ -11,9 +11,6 @@ module Gitlab
module Ldap module Ldap
class User < Gitlab::Auth::OAuth::User class User < Gitlab::Auth::OAuth::User
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
def save
super(protocol_name)
end
# instance methods # instance methods
def find_user def find_user
......
...@@ -46,7 +46,7 @@ module Gitlab ...@@ -46,7 +46,7 @@ module Gitlab
valid? && persisted? valid? && persisted?
end end
def save(provider = 'OAuth') def save(provider = protocol_name)
raise SigninDisabledForProviderError if oauth_provider_disabled? raise SigninDisabledForProviderError if oauth_provider_disabled?
raise SignupDisabledError unless gl_user raise SignupDisabledError unless gl_user
...@@ -97,7 +97,7 @@ module Gitlab ...@@ -97,7 +97,7 @@ module Gitlab
end end
def protocol_name def protocol_name
'' 'OAuth'
end end
protected protected
......
...@@ -11,10 +11,6 @@ module Gitlab ...@@ -11,10 +11,6 @@ module Gitlab
class User < Gitlab::Auth::OAuth::User class User < Gitlab::Auth::OAuth::User
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
def save
super(protocol_name)
end
def find_user def find_user
user = find_by_uid_and_provider user = find_by_uid_and_provider
......
...@@ -587,7 +587,7 @@ RSpec.describe Gitlab::Auth::OAuth::User do ...@@ -587,7 +587,7 @@ RSpec.describe Gitlab::Auth::OAuth::User do
context 'when a sign up user cap has been set up but has not been reached yet' do context 'when a sign up user cap has been set up but has not been reached yet' do
it 'still creates a blocked user' do it 'still creates a blocked user' do
allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(999) stub_application_setting(new_user_signups_cap: 999)
oauth_user.save # rubocop:disable Rails/SaveBang oauth_user.save # rubocop:disable Rails/SaveBang
expect(gl_user).to be_valid expect(gl_user).to be_valid
...@@ -612,9 +612,9 @@ RSpec.describe Gitlab::Auth::OAuth::User do ...@@ -612,9 +612,9 @@ RSpec.describe Gitlab::Auth::OAuth::User do
before do before do
stub_omniauth_config({ stub_omniauth_config({
allow_single_sign_on: ['saml'], allow_single_sign_on: ['saml'],
auto_link_saml_user: true, auto_link_saml_user: true,
block_auto_created_users: block_auto_created_users block_auto_created_users: block_auto_created_users
}) })
end end
...@@ -1049,8 +1049,8 @@ RSpec.describe Gitlab::Auth::OAuth::User do ...@@ -1049,8 +1049,8 @@ RSpec.describe Gitlab::Auth::OAuth::User do
end end
describe '#protocol_name' do describe '#protocol_name' do
it 'is empty' do it 'is OAuth' do
expect(oauth_user.protocol_name).to eq('') expect(oauth_user.protocol_name).to eq('OAuth')
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment