module ZuoraConnect::Controllers::Helpers
def authenticate_app_api_request
def authenticate_app_api_request start_time = Time.now if !request.headers["API-Token"].blank? @appinstance = ZuoraConnect::AppInstance.where(:api_token => request.headers["API-Token"]).first Rails.logger.debug("[#{@appinstance.id}] API REQUEST - API token") if !@appinstance.blank? check_instance else authenticate_or_request_with_http_basic do |username, password| @appinstance = ZuoraConnect::AppInstance.where(:token => password).first @appinstance ||= ZuoraConnect::AppInstance.where(:api_token => password).first Rails.logger.debug("[#{@appinstance.id}] API REQUEST - Basic Auth") if !@appinstance.blank? check_instance end end Rails.logger.debug("[#{@appinstance.blank? ? "N/A" : @appinstance.id}] Authenticate App API Request Completed In - #{(Time.now - start_time).round(2)}s") end