Sha256: 363487a2d4d860f70a2ca28542f9c1fa4585701d10b10d52835666dc6510b325
Contents?: true
Size: 1.64 KB
Versions: 10
Compression:
Stored size: 1.64 KB
Contents
class FanforceApp::Sinatra def route_index_ui page :index, :layout => :promotional end def route_config_ui page :config, :layout => :config end def route_close_popup_ui page :close_popup end def route_install_callback raise "This is not a valid app install request: #{env['HTTP_HOST']}" if !ff.valid_install_request?(params) api_key = $Redis.get("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}") if api_key.present? and api_key != params[:api_key] is_valid_key = Fanforce::API.new.get("/api_auths/is_valid_key/#{params[:api_key]}", organization_id: params[:organization_id], app_id: params[:app_id])[:result] raise 'A different API key already exists for this app. Please uninstall first.' if !is_valid_key end $Redis.set("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}", params[:api_key]) ff.auth(params[:api_key]) json status: 'finished-processing' end def route_uninstall_callback raise 'This is not a valid app uninstall request.' if !ff.valid_uninstall_request?(params) api_key = $Redis.get("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}") if api_key.present? and api_key != params[:api_key] is_valid_key = Fanforce::API.new.get("/api_auths/is_valid_key/#{params[:api_key]}", organization_id: params[:organization_id], app_id: params[:app_id])[:result] raise 'API keys must match before an app can be uninstalled.' if !is_valid_key end $Redis.del("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}") json status: 'finished-processing' end def route_ping_pong json success: true end end
Version data entries
10 entries across 10 versions & 1 rubygems