From 20a88f5c43efa3ab0af80d26c90268132e6f7997 Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Mon, 29 Apr 2013 22:26:03 +0200 Subject: [PATCH] LDAP authentication in grack - check ldap conf before call / added comment --- lib/gitlab/backend/grack_auth.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 9de68283d..f46455f47 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -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) -- 2.11.0