gitlab-org--gitlab-foss/lib/gitlab/auth.rb

19 lines
499 B
Ruby
Raw Normal View History

2012-09-12 06:23:16 +00:00
module Gitlab
class Auth
2013-07-16 08:28:19 +00:00
def find(login, password)
user = User.by_login(login)
2013-07-16 08:28:19 +00:00
# If no user is found, or it's an LDAP server, try LDAP.
# LDAP users are only authenticated via LDAP
2013-07-16 08:28:19 +00:00
if user.nil? || user.ldap_user?
# Second chance - try LDAP authentication
return nil unless Gitlab::LDAP::Config.enabled?
2013-07-16 08:28:19 +00:00
Gitlab::LDAP::Authentication.login(login, password)
2013-07-16 08:28:19 +00:00
else
user if user.valid_password?(password)
end
end
2012-09-12 06:23:16 +00:00
end
end