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]}:#{
|
14
|
+
api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{params[:organization_id]}")
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
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]}:#{
|
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
|
30
|
-
$Redis.del("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_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
|