2012-09-20 16:44:44 +02:00
|
|
|
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
|
2012-09-20 16:44:44 +02:00
|
|
|
|
|
|
|
if resource.valid_password?(params[:password])
|
|
|
|
present resource, with: Entities::UserLogin
|
|
|
|
else
|
2012-09-20 17:38:08 +02:00
|
|
|
unauthorized!
|
2012-09-20 16:44:44 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|