fanforce-app-factory 0.36.0 → 0.37.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,11 +11,14 @@ class FanforceApp::Sinatra
11
11
  # INSTALL ######################################################################
12
12
  def route_install(params)
13
13
  raise "This is not a valid app install request: #{env['HTTP_HOST']}" if !ff.valid_install_request?(params)
14
- api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:organization_id]}")
14
+ api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{params[:organization_id]}")
15
15
 
16
- #raise 'A different API key already exists for this addon. Please uninstall first.' if api_key.present? and ff.params[:api_key] != api_key
17
- $Redis.set("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:organization_id]}", ff.params[:api_key])
18
- ff.auth(ff.params[:api_key])
16
+ if api_key.present? and api_key != params[:api_key]
17
+ 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]
18
+ raise 'A different API key already exists for this addon. Please uninstall first.' if !is_valid_key
19
+ end
20
+ $Redis.set("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{params[:organization_id]}", params[:api_key])
21
+ ff.auth(params[:api_key])
19
22
 
20
23
  json status: 'finished-processing'
21
24
  end
@@ -24,10 +27,10 @@ class FanforceApp::Sinatra
24
27
  # UNINSTALL ####################################################################
25
28
  def route_uninstall(params)
26
29
  raise 'This is not a valid app uninstall request.' if !ff.valid_uninstall_request?(params)
27
- api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:organization_id]}")
30
+ api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{params[:organization_id]}")
28
31
 
29
- raise 'API keys must match before an addon can be uninstalled.' if api_key.present? and ff.params[:api_key] != api_key
30
- $Redis.del("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:organization_id]}")
32
+ raise 'API keys must match before an addon can be uninstalled.' if api_key.present? and params[:api_key] != api_key
33
+ $Redis.del("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{params[:organization_id]}")
31
34
  json status: 'finished-processing'
32
35
  end
33
36
  any '/uninstall' do route_uninstall(params) end
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  module AppFactory
3
- VERSION = '0.36.0'
3
+ VERSION = '0.37.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-app-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.0
4
+ version: 0.37.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: