module Sinatra::FanforceHelpers require 'fanforce' def fanforce_id @fanforce_id = params[:fanforce_id] || ff.params[:fanforce_id] end def ff return @ff if @ff.present? @ff = Fanforce::API.new(params) #return @ff if !@ff.valid_fanforce_request? and !@ff.valid_fanforce_js_request? @ff.auth Sinatra::FanforceHelpers.find_api_key(ff.params[:fanforce_id]) @ff end def self.find_api_key(fanforce_id, addon_type=:app, addon_id=FanforceApp._id) $Redis.get("installed:#{addon_type}-#{addon_id}:#{fanforce_id}") end end