2014-09-02 18:07:02 +05:30
|
|
|
module API
|
|
|
|
# Users 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
|
2016-06-16 23:09:34 +05:30
|
|
|
user = Gitlab::Auth.find_with_user_password(params[:email] || params[:login], params[:password])
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
return unauthorized! unless user
|
|
|
|
present user, with: Entities::UserLogin
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|