Only initialize if ldap is enabled

parent 18d87dcf
module OmniAuth::Strategies if Gitlab::LDAP::Config.enabled?
Gitlab::LDAP::Config.servers.each do |server| module OmniAuth::Strategies
# do not redeclare LDAP Gitlab::LDAP::Config.servers.each do |server|
next if server['provider_name'] == 'ldap' # do not redeclare LDAP
const_set(server['provider_class'], Class.new(LDAP)) next if server['provider_name'] == 'ldap'
const_set(server['provider_class'], Class.new(LDAP))
end
end end
end
OmniauthCallbacksController.class_eval do OmniauthCallbacksController.class_eval do
Gitlab::LDAP::Config.servers.each do |server| Gitlab::LDAP::Config.servers.each do |server|
alias_method server['provider_name'], :ldap alias_method server['provider_name'], :ldap
end
end end
end end
\ No newline at end of file
...@@ -204,7 +204,7 @@ Devise.setup do |config| ...@@ -204,7 +204,7 @@ Devise.setup do |config|
# manager.default_strategies(scope: :user).unshift :some_external_strategy # manager.default_strategies(scope: :user).unshift :some_external_strategy
# end # end
if Gitlab.config.ldap.enabled if Gitlab::LDAP::Config.enabled?
Gitlab::LDAP::Config.servers.each do |server| Gitlab::LDAP::Config.servers.each do |server|
if server['allow_username_or_email_login'] if server['allow_username_or_email_login']
email_stripping_proc = ->(name) {name.gsub(/@.*$/,'')} email_stripping_proc = ->(name) {name.gsub(/@.*$/,'')}
......
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