zuora_connect 2.0.3d → 2.0.3e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4ef5785c65d1716ad492175066157cca6cc97f04237469f7e985e2d8c56f127
|
4
|
+
data.tar.gz: 4bddd005e38fdb052f14e5719f36082a0bf586ddd53facfa8d5c4fe65764f969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44d4393dc0e0af6a1164ea7e82bd77a98ffb3dad1be8f10b813d9c912a7724e05f7879cd87604d857bbe6bd1f26e4cb8343873f8a64abed17eb9908931e4e205
|
7
|
+
data.tar.gz: 97b8cfc082d665224dd2063438ee3ba785473dc735449fb8a93378ae64a1694e5c3d46cc95774a9c0e1564063fa2d86e6a710ceea4374b875625cbee45529417
|
@@ -200,7 +200,7 @@ module ZuoraConnect
|
|
200
200
|
:zuora_entity_ids => self.task_data.dig(LOGIN_TENANT_DESTINATION,'entities').map{|e| e['id']},
|
201
201
|
:zuora_tenant_ids => self.task_data['tenant_ids'],
|
202
202
|
}
|
203
|
-
params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) }
|
203
|
+
params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) || self[k] == v}
|
204
204
|
self.update_columns(params) if params.present?
|
205
205
|
end
|
206
206
|
|
@@ -67,10 +67,10 @@
|
|
67
67
|
<input type="hidden" id="name_hash" value="<%= @names.to_s %>" />
|
68
68
|
<input type="hidden" id="app_instance_list" value="<%= @app_instance_ids.to_s %>" />
|
69
69
|
|
70
|
-
<% @
|
70
|
+
<% @names.each do |id, name| %>
|
71
71
|
<div class="button">
|
72
|
-
<% label =
|
73
|
-
<%= link_to label, root_path(
|
72
|
+
<% label = name.present? ? "#{id} - #{name}" : id %>
|
73
|
+
<%= link_to label, root_path(app_instance_id: id) %>
|
74
74
|
</div>
|
75
75
|
<% end %>
|
76
76
|
</div>
|
@@ -106,68 +106,106 @@ module ZuoraConnect
|
|
106
106
|
ElasticAPM.set_tag(:trace_id, request.uuid) if defined?(ElasticAPM) && ElasticAPM.running?
|
107
107
|
Thread.current[:appinstance] = nil
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
109
|
+
if request.headers['Zuora-Auth-Token'].present? && request.headers["NEWZUORA"].present?
|
110
|
+
|
111
|
+
#Debug
|
112
|
+
headers = request.headers.env.select do |k, _|
|
113
|
+
k.downcase.start_with?('http') ||
|
114
|
+
k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES)
|
115
|
+
end
|
116
|
+
puts headers
|
117
|
+
|
118
|
+
#Do we need to refresh session identity
|
119
|
+
zuora_host = request.headers["HTTP_X_FORWARDED_HOST"] || "apisandbox.zuora.com"
|
120
|
+
zuora_client = ZuoraAPI::Login.new(url: "https://#{zuora_host}", session: cookies['ZSession'])
|
121
|
+
zuora_entity_id = request.headers['ZuoraCurrentEntity']
|
122
|
+
zuora_instance_id = params[:sidebar_launch].to_bool ? nil : (params[:app_instance_id] || session["appInstance"])
|
123
|
+
|
124
|
+
#Identity blank or current entity different
|
125
|
+
if (session["ZuoraCurrentIdentity"].blank? || session["ZuoraCurrentEntity"] != zuora_entity_id)
|
126
|
+
begin
|
127
|
+
identity, response = zuora_client.rest_call(url: zuora_client.rest_endpoint("identity"))
|
128
|
+
session["ZuoraCurrentIdentity"] = identity
|
129
|
+
session["ZuoraCurrentEntity"] = identity['entityId']
|
130
|
+
|
131
|
+
raise "Header entity id does not match identity call entity id" if zuora_entity_id != identity['entityId']
|
132
|
+
rescue => ex
|
133
|
+
ZuoraConnect.logger.error(ex)
|
134
|
+
render "zuora_connect/static/invalid_launch_request"
|
135
|
+
return
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
#Find matching app instances.
|
140
|
+
if zuora_instance_id.present?
|
141
|
+
appinstances = ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host AND id = :id", entities: [zuora_entity_id], host: zuora_client.rest_domain, id: zuora_instance_id).pluck(:id, :name)
|
142
|
+
else
|
143
|
+
appinstances = ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host", entities: [zuora_entity_id], host: zuora_client.rest_domain).pluck(:id, :name)
|
144
|
+
end
|
145
|
+
|
146
|
+
#One deployed instance
|
147
|
+
if appinstances.size == 1
|
148
|
+
ZuoraConnect.logger.debug("Instance is #{appinstances.to_h.keys.first}")
|
149
|
+
session["appInstance"] = appinstances.to_h.keys.first
|
150
|
+
|
151
|
+
#We have multiple, user must pick
|
152
|
+
elsif appinstances.size > 1
|
153
|
+
ZuoraConnect.logger.debug("User must select instance. #{@names}")
|
154
|
+
@names = appinstances.to_h
|
155
|
+
render "zuora_connect/static/launch"
|
123
156
|
return
|
157
|
+
else
|
158
|
+
#Create new app instance
|
159
|
+
raise "Do not support new instance creation right now."
|
124
160
|
end
|
125
161
|
end
|
126
162
|
|
127
|
-
if params[:app_instance_ids].present?
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
163
|
+
if params[:app_instance_ids].present?
|
164
|
+
if !params[:app_instance_id].present?
|
165
|
+
begin
|
166
|
+
app_instance_ids = JSON.parse(Base64.urlsafe_decode64(params[:app_instance_ids]))
|
167
|
+
if app_instance_ids.length == 1
|
168
|
+
verify_with_navbar
|
169
|
+
instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
|
170
|
+
if instances.include?(app_instance_ids[0])
|
171
|
+
@appinstance = ZuoraConnect::AppInstance.find(app_instance_ids[0])
|
172
|
+
@appinstance.new_session(session: {})
|
173
|
+
@appinstance.cache_app_instance
|
174
|
+
session["appInstance"] = app_instance_ids[0]
|
175
|
+
else
|
176
|
+
ZuoraConnect.logger.error("Launch Error: Param Instance didnt match session data")
|
177
|
+
render "zuora_connect/static/invalid_launch_request"
|
178
|
+
return
|
179
|
+
end
|
180
|
+
else
|
181
|
+
select_instance
|
182
|
+
return
|
183
|
+
end
|
184
|
+
rescue => ex
|
185
|
+
ZuoraConnect.logger.error(ex)
|
186
|
+
render "zuora_connect/static/invalid_launch_request"
|
187
|
+
return
|
188
|
+
end
|
189
|
+
elsif params[:app_instance_id].present?
|
190
|
+
begin
|
132
191
|
instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
|
133
|
-
if instances.include?(
|
134
|
-
@appinstance = ZuoraConnect::AppInstance.find(
|
192
|
+
if instances.include?(params[:app_instance_id].to_i)
|
193
|
+
@appinstance = ZuoraConnect::AppInstance.find(params[:app_instance_id].to_i)
|
135
194
|
@appinstance.new_session(session: {})
|
136
195
|
@appinstance.cache_app_instance
|
137
|
-
session["appInstance"] =
|
196
|
+
session["appInstance"] = params[:app_instance_id].to_i
|
138
197
|
else
|
139
|
-
ZuoraConnect.logger.error("Launch Error: Param Instance didnt match session data")
|
140
198
|
render "zuora_connect/static/invalid_launch_request"
|
141
199
|
return
|
142
200
|
end
|
143
|
-
|
144
|
-
|
145
|
-
return
|
146
|
-
end
|
147
|
-
rescue => ex
|
148
|
-
ZuoraConnect.logger.error(ex)
|
149
|
-
render "zuora_connect/static/invalid_launch_request"
|
150
|
-
return
|
151
|
-
end
|
152
|
-
|
153
|
-
elsif params[:app_instance_ids].present? && params[:app_instance_id].present?
|
154
|
-
begin
|
155
|
-
instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
|
156
|
-
if instances.include?(params[:app_instance_id].to_i)
|
157
|
-
@appinstance = ZuoraConnect::AppInstance.find(params[:app_instance_id].to_i)
|
158
|
-
@appinstance.new_session(session: {})
|
159
|
-
@appinstance.cache_app_instance
|
160
|
-
session["appInstance"] = params[:app_instance_id].to_i
|
161
|
-
else
|
201
|
+
rescue => ex
|
202
|
+
ZuoraConnect.logger.error(ex)
|
162
203
|
render "zuora_connect/static/invalid_launch_request"
|
163
204
|
return
|
164
205
|
end
|
165
|
-
rescue => ex
|
166
|
-
ZuoraConnect.logger.error(ex)
|
167
|
-
render "zuora_connect/static/invalid_launch_request"
|
168
|
-
return
|
169
206
|
end
|
170
207
|
end
|
208
|
+
|
171
209
|
start_time = Time.now
|
172
210
|
if ZuoraConnect.configuration.mode == "Production"
|
173
211
|
if request["data"] && /^([A-Za-z0-9+\/\-\_]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)$/.match(request["data"].to_s)
|