OSDN Git Service

LDAP authentication in grack - check ldap conf before call / added comment
authorFriedrich Beckmann <friedrich.beckmann@hs-augsburg.de>
Mon, 29 Apr 2013 20:26:03 +0000 (22:26 +0200)
committerFriedrich Beckmann <friedrich.beckmann@hs-augsburg.de>
Mon, 29 Apr 2013 20:26:03 +0000 (22:26 +0200)
lib/gitlab/backend/grack_auth.rb

index 9de6828..f46455f 100644 (file)
@@ -34,11 +34,15 @@ module Grack
         login, password = @auth.credentials
         self.user = User.find_by_email(login) || User.find_by_username(login)
 
-        if user.nil?
+        # If the provided login was not a known email or username
+        # then user is nil
+        if user.nil? 
+          # Second chance - try LDAP authentication
+          return false unless Gitlab.config.ldap.enabled         
           ldap_auth(login,password)
           return false unless !user.nil?
         else
-          return false unless user.valid_password?(password);
+          return false unless user.valid_password?(password)
         end
            
         Gitlab::ShellEnv.set_env(user)