gitlabhq/lib/api/session.rb

21 lines
444 B
Ruby
Raw Normal View History

module Gitlab
# Users API
class Session < Grape::API
# Login to get token
#
# Example Request:
# POST /session
post "/session" do
resource = User.find_for_database_authentication(email: params[:email])
2012-09-20 17:38:08 +02:00
return unauthorized! unless resource
if resource.valid_password?(params[:password])
present resource, with: Entities::UserLogin
else
2012-09-20 17:38:08 +02:00
unauthorized!
end
end
end
end