Skip to content

Commit

Permalink
Refactor: Moved the check for an empty DN to authenticate_dn
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3449 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
edavis10 committed Feb 18, 2010
1 parent 899fb10 commit 82dd1b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/auth_source_ldap.rb
Expand Up @@ -45,10 +45,9 @@ def authenticate(login, password)
:attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry|
dn = entry.dn
attrs = get_user_attributes_from_ldap_entry(entry) if onthefly_register?
logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?

end
return nil if dn.empty?
logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?

if authenticate_dn(dn, password)
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
Expand Down Expand Up @@ -100,6 +99,8 @@ def get_user_attributes_from_ldap_entry(entry)

# Check if a DN (user record) authenticates with the password
def authenticate_dn(dn, password)
return nil if dn.empty?

ldap_con = initialize_ldap_con(dn, password)
return ldap_con.bind
end
Expand Down

0 comments on commit 82dd1b2

Please sign in to comment.