class ApiAuthsController < ApiController

  respond_to :json

  def login
    user = User.authenticate(params[:email], params[:password])

    if user.nil?
      render :json => {}, :status => 422
    else
      if jkclient_agent?
        user.update_progression_field(:first_ran_client_at)
      end

      @session_only_cookie = !jkclient_agent? && !params[:remember_me]

      complete_sign_in(user, redirect=false)

      render :json => { 
        first_name: user.first_name,
        last_name: user.last_name,
        photo_url: user.photo_url,
        id: user.id,
        email: user.email
      }, :status => :ok
    end
  end
end
