module ZuoraConnect::Controllers::Helpers

def authenticate_app_api_request

def authenticate_app_api_request
  authenticate_or_request_with_http_basic do |username, password|
    @appinstance = ZuoraConnect::AppInstance.where(:token => password).first
    if !@appinstance.blank?
      @appinstance.new_session(:session => {})
      Thread.current[:appinstance] = @appinstance
      return  @appinstance.valid
    else
      render text: "Access Denied", status: :unauthorized
    end
  end
end