auth.rb 519 字节
Newer Older
D
Dmitriy Zaporozhets 已提交
1 2
module Gitlab
  class Auth
3
    def find(login, password)
S
skv 已提交
4
      user = User.find_by(email: login) || User.find_by(username: login)
5 6 7 8 9

      if user.nil? || user.ldap_user?
        # Second chance - try LDAP authentication
        return nil unless ldap_conf.enabled

D
Dmitriy Zaporozhets 已提交
10
        Gitlab::LDAP::User.authenticate(login, password)
11 12 13 14 15
      else
        user if user.valid_password?(password)
      end
    end

D
Dmitriy Zaporozhets 已提交
16 17 18
    def log
      Gitlab::AppLogger
    end
19 20 21 22

    def ldap_conf
      @ldap_conf ||= Gitlab.config.ldap
    end
D
Dmitriy Zaporozhets 已提交
23 24
  end
end