gitlabhq/lib/api/session.rb
2012-09-20 08:38:08 -07:00

21 lines
444 B
Ruby

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])
return unauthorized! unless resource
if resource.valid_password?(params[:password])
present resource, with: Entities::UserLogin
else
unauthorized!
end
end
end
end