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

19 lines
499 B
Ruby
Raw Normal View History

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