end
def ldap_enabled?
- ldap['enabled']
- rescue
+ ldap && ldap['enabled']
+ rescue Settingslogic::MissingSetting
false
end
def omniauth_enabled?
omniauth && omniauth['enabled']
- rescue
+ rescue Settingslogic::MissingSetting
false
end
def omniauth_providers
- omniauth['providers'] || []
+ (omniauth_enabled? && omniauth['providers']) || []
end
def disable_gravatar?
end
end
- def create_from_omniauth auth, ldap = false
+ def create_from_omniauth(auth, ldap = false)
provider = auth.provider
uid = auth.info.uid || auth.uid
name = auth.info.name.force_encoding("utf-8")
password_confirmation: password,
projects_limit: Gitlab.config.default_projects_limit,
)
- if Gitlab.config.omniauth.block_auto_created_users && !ldap
+ if Gitlab.config.omniauth['block_auto_created_users'] && !ldap
@user.blocked = true
end
@user.save!
if @user = User.find_by_provider_and_extern_uid(provider, uid)
@user
else
- if Gitlab.config.omniauth.allow_single_sign_on
+ if Gitlab.config.omniauth['allow_single_sign_on']
@user = create_from_omniauth(auth)
@user
end
let(:gl_auth) { Gitlab::Auth.new }
before do
+ Gitlab.config.stub(omniauth: {})
+
@info = mock(
uid: '12djsak321',
name: 'John',
end
it "should create user if single_sing_on"do
- Gitlab.config.omniauth.stub allow_single_sign_on: true
+ Gitlab.config.omniauth['allow_single_sign_on'] = true
User.stub find_by_provider_and_extern_uid: nil
gl_auth.should_receive :create_from_omniauth
gl_auth.find_or_new_for_omniauth(@auth)