2013-05-14 08:33:31 -04:00
|
|
|
module API
|
2012-09-20 10:44:44 -04:00
|
|
|
# Users API
|
|
|
|
class Session < Grape::API
|
|
|
|
# Login to get token
|
|
|
|
#
|
2013-07-16 04:28:19 -04:00
|
|
|
# Parameters:
|
|
|
|
# login (*required) - user login
|
|
|
|
# email (*required) - user email
|
|
|
|
# password (required) - user password
|
|
|
|
#
|
2012-09-20 10:44:44 -04:00
|
|
|
# Example Request:
|
|
|
|
# POST /session
|
|
|
|
post "/session" do
|
2013-07-16 04:28:19 -04:00
|
|
|
auth = Gitlab::Auth.new
|
|
|
|
user = auth.find(params[:email] || params[:login], params[:password])
|
2012-09-20 10:44:44 -04:00
|
|
|
|
2013-07-16 04:28:19 -04:00
|
|
|
return unauthorized! unless user
|
|
|
|
present user, with: Entities::UserLogin
|
2012-09-20 10:44:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|