Sha256: ae2db0e91d10475afaf99b61fc4e38e69003ade4e219051646b8a84ee433a88d

Contents?: true

Size: 1.65 KB

Versions: 18

Compression:

Stored size: 1.65 KB

Contents

class Fanforce::App::Sinatra

  def route_index_ui
    page :index, :layout => :promotional
  end

  def route_config_ui
    page :config, :layout => :fembedded
  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']}): #{params.to_s}" if !ff.valid_install_request?(params)
    api_key = App.redis.get("installed:app-#{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
    App.redis.set("installed:app-#{params[:app_id]}:#{params[:organization_id]}", params[:api_key])
    ff.set_auth(params[:api_key])

    json status: 'finished'
  end

  def route_uninstall_callback
    raise 'This is not a valid app uninstall request.' if !ff.valid_uninstall_request?(params)
    api_key = App.redis.get("installed:app-#{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
    App.redis.del("installed:app-#{params[:app_id]}:#{params[:organization_id]}")

    json status: 'finished'
  end

  def route_ping_callback
    json success: true
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc24 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc23 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc22 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc21 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc20 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc19 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc18 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc17 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc16 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc15 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc14 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc13 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc12 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc11 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc10 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc9 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc8 lib/fanforce/app_factory/sinatra/helper_routes/app.rb
fanforce-app-factory-2.0.0.rc7 lib/fanforce/app_factory/sinatra/helper_routes/app.rb