summaryrefslogtreecommitdiff
path: root/lib/gitlab/auth.rb
blob: 30509528b8b6ba5a44d32b47e382d8906b61f9d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Gitlab
  class Auth
    def find(login, password)
      user = User.by_login(login)

      # If no user is found, or it's an LDAP server, try LDAP.
      #   LDAP users are only authenticated via LDAP
      if user.nil? || user.ldap_user?
        # Second chance - try LDAP authentication
        return nil unless Gitlab::LDAP::Config.enabled?

        Gitlab::LDAP::Authentication.login(login, password)
      else
        user if user.valid_password?(password)
      end
    end
  end
end