]> source.dussan.org Git - redmine.git/commitdiff
Refactor: Rewrite authenticate_dn to use an implicit return.
authorEric Davis <edavis@littlestreamsoftware.com>
Thu, 18 Feb 2010 16:55:10 +0000 (16:55 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Thu, 18 Feb 2010 16:55:10 +0000 (16:55 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3450 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/auth_source_ldap.rb

index da453ae981498c0ee0cc092faecbebd77e9078b9..4f73621d6957279cf345c467a9a2aa4cb7f4ba7f 100644 (file)
@@ -52,8 +52,6 @@ class AuthSourceLdap < AuthSource
     if authenticate_dn(dn, password)
       logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
       return attrs
-    else
-      return nil
     end
   rescue  Net::LDAP::LdapError => text
     raise "LdapError: " + text
@@ -99,10 +97,9 @@ class AuthSourceLdap < AuthSource
 
   # 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
+    if dn.present? && password.present?
+      initialize_ldap_con(dn, password).bind
+    end
   end
   
   def self.get_attr(entry, attr_name)