diff --git a/app/models/auth_source.rb b/app/models/auth_source.rb index 092a05af4f..a899457201 100644 --- a/app/models/auth_source.rb +++ b/app/models/auth_source.rb @@ -69,10 +69,10 @@ class AuthSource < ActiveRecord::Base def self.authenticate(login, password) AuthSource.where(['onthefly_register=?', true]).each do |source| begin - logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug? + Rails.logger.debug { "Authenticating '#{login}' against '#{source.name}'" } attrs = source.authenticate(login, password) rescue => e - logger.error "Error during authentication: #{e.message}" + Rails.logger.error "Error during authentication: #{e.message}" attrs = nil end return attrs if attrs diff --git a/app/models/ldap_auth_source.rb b/app/models/ldap_auth_source.rb index 9ff046cef3..b794523588 100644 --- a/app/models/ldap_auth_source.rb +++ b/app/models/ldap_auth_source.rb @@ -44,7 +44,7 @@ class LdapAuthSource < AuthSource attrs = get_user_dn(login) if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password) - logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? + Rails.logger.debug { "Authentication successful for '#{login}'" } return attrs.except(:dn) end rescue Net::LDAP::LdapError => error @@ -115,6 +115,9 @@ class LdapAuthSource < AuthSource object_filter = Net::LDAP::Filter.eq('objectClass', '*') attrs = {} + Rails.logger.debug { + "LDAP initializing search (BASE=#{base_dn}), (FILTER=#{(object_filter & login_filter).to_s})" + } ldap_con.search(base: base_dn, filter: object_filter & login_filter, attributes: search_attributes) do |entry| @@ -124,7 +127,7 @@ class LdapAuthSource < AuthSource attrs = { dn: entry.dn } end - logger.debug "DN found for #{login}: #{attrs[:dn]}" if logger && logger.debug? + Rails.logger.debug { "DN found for #{login}: #{attrs[:dn]}" } end attrs