<commit_before>
class Rest::BaseController < UiController

  skip_before_filter :bootstrap_current_user
  skip_before_filter :bootstrap_users
  around_action :catch_exceptions

  private

  # Check for a valid user session or API authentication header
  #
  # @return [Boolean] true if the request is not authenticated (user must login)
  def authenticate_user!
    # check for API/signed requests
    if request.headers.env["HTTP_AUTHORIZATION"] || request.headers.env["Authorization"] then
      agent = Agent.where(:access_key => ApiAuth.access_id(request)).first
      begin
        if not(agent and ApiAuth.authentic?(request, agent.secret_key)) then
          return render :text => Bixby::JsonResponse.new("fail", "authentication failed", nil, 401).to_json, :status => 401
        end
      rescue ApiAuth::ApiAuthError => ex
        return render :text => Bixby::JsonResponse.new("fail", ex.message, nil, 401).to_json, :status => 401
      end
      @current_user = agent # TODO hrm.. hack much?
      return false
    end

    # authenticate a request from a browser session (via devise)
    super
  end

  # Handle any thrown exception and return a proper response
  def catch_exceptions

    $stdout.puts "HI"
    STDOUT.puts "HI"
    STDOUT.puts "HI"
    STDOUT.puts "HI"
    STDOUT.puts "HI"
    STDOUT.flush
    logger.warn STDOUT.inspect
    Logging.reopen
    logger.warn logger.inspect
    logger.warn logger.parent.appenders.inspect

    begin
      yield
    rescue Exception => ex
      if ex.kind_of? MissingParam then
        return render(:text => ex.message, :status => 400)
      end
      raise
    end

  end

end<commit_msg>remove logging<commit_after>
class Rest::BaseController < UiController

  skip_before_filter :bootstrap_current_user
  skip_before_filter :bootstrap_users
  around_action :catch_exceptions

  private

  # Check for a valid user session or API authentication header
  #
  # @return [Boolean] true if the request is not authenticated (user must login)
  def authenticate_user!
    # check for API/signed requests
    if request.headers.env["HTTP_AUTHORIZATION"] || request.headers.env["Authorization"] then
      agent = Agent.where(:access_key => ApiAuth.access_id(request)).first
      begin
        if not(agent and ApiAuth.authentic?(request, agent.secret_key)) then
          return render :text => Bixby::JsonResponse.new("fail", "authentication failed", nil, 401).to_json, :status => 401
        end
      rescue ApiAuth::ApiAuthError => ex
        return render :text => Bixby::JsonResponse.new("fail", ex.message, nil, 401).to_json, :status => 401
      end
      @current_user = agent # TODO hrm.. hack much?
      return false
    end

    # authenticate a request from a browser session (via devise)
    super
  end

  # Handle any thrown exception and return a proper response
  def catch_exceptions

    begin
      yield
    rescue Exception => ex
      if ex.kind_of? MissingParam then
        return render(:text => ex.message, :status => 400)
      end
      raise
    end

  end

end
{'fraction_non_alphanumeric': 0.0871559633027523, 'fraction_numerical': 0.009829619921363041, 'mean_word_length': 3.1368563685636857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2219329', 'n_tokens_mistral': 931, 'n_tokens_neox': 882, 'n_words': 272}