diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-07-16 12:28:19 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-07-16 12:28:19 +0400 |
commit | 559e83d30004e0c41a30f4ce3463f695eb7e26a1 (patch) | |
tree | 3bc2c0ad1e613683456a786544126221767601a3 /lib/api/session.rb | |
parent | a6cfb54c88f34127a696992041c5690885baa6f5 (diff) |
Add LDAP support to /api/session
Diffstat (limited to 'lib/api/session.rb')
-rw-r--r-- | lib/api/session.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/api/session.rb b/lib/api/session.rb index 509acded51e..cc646895914 100644 --- a/lib/api/session.rb +++ b/lib/api/session.rb @@ -3,18 +3,19 @@ module API class Session < Grape::API # Login to get token # + # Parameters: + # login (*required) - user login + # email (*required) - user email + # password (required) - user password + # # Example Request: # POST /session post "/session" do - resource = User.find_for_database_authentication(email: params[:email]) - - return unauthorized! unless resource + auth = Gitlab::Auth.new + user = auth.find(params[:email] || params[:login], params[:password]) - if resource.valid_password?(params[:password]) - present resource, with: Entities::UserLogin - else - unauthorized! - end + return unauthorized! unless user + present user, with: Entities::UserLogin end end end |