zuora_connect 2.0.5p → 2.0.5q
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d533bc392f7e7b927a1cbcd99fb2e83efb1d84adf57378e114e62e9f1167d94c
|
4
|
+
data.tar.gz: c7182d8e36035223fe1db8711094772890e8dcb5ad3dbe77a00e2d63018f1e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 113fb44242e94367e01f08a0948f1181b254a4418a3da25dfc4a698758eab1dd5dd763a40ed747e580bd50645b36deb08291a0e60c48ef6c37972c59eb61b0f1
|
7
|
+
data.tar.gz: c02a67c7a5fb41c97e17ffbe3444a003d753ae1113678c5abfebdd4b37124f40572cc0744a50f7109fcbfd07da0d4dd2949082dfbbd15fd58beb76fd93190465
|
@@ -16,7 +16,7 @@ module ZuoraConnect
|
|
16
16
|
BLANK_OBJECT_ID_LOOKUP = 'BlankValueSupplied'
|
17
17
|
HOLDING_PATTERN_SLEEP = 5.seconds
|
18
18
|
CONNECT_COMMUNICATION_SLEEP= 5.seconds
|
19
|
-
IGNORED_LOCALS = ['fr', 'ja', '
|
19
|
+
IGNORED_LOCALS = ['fr', 'ja', 'es', 'zh']
|
20
20
|
INTERNAL_HOSTS = []
|
21
21
|
LOGIN_TENANT_DESTINATION = 'target_login'
|
22
22
|
|
@@ -170,17 +170,18 @@ module ZuoraConnect
|
|
170
170
|
@zuora_user.zuora_identity_response[zuora_entity_id] = session["ZuoraCurrentIdentity"]
|
171
171
|
@zuora_user.save!
|
172
172
|
end
|
173
|
-
|
174
|
-
session["#{@appinstance.id}::user::email"] = session["username"]
|
175
173
|
else
|
176
174
|
ZuoraConnect.logger.debug("New zuora user object for #{zuora_user_id}")
|
177
175
|
@zuora_user = ZuoraConnect::ZuoraUser.create!(:zuora_user_id => zuora_user_id, :zuora_identity_response => {zuora_entity_id => session["ZuoraCurrentIdentity"]})
|
178
176
|
end
|
179
177
|
@zuora_user.session = session
|
178
|
+
session["#{@appinstance.id}::user::email"] = session['ZuoraCurrentIdentity']["username"]
|
179
|
+
session["#{@appinstance.id}::user::timezone"] = session['ZuoraCurrentIdentity']["timeZone"]
|
180
|
+
session["#{@appinstance.id}::user::locale"] = session['ZuoraCurrentIdentity']["language"]
|
180
181
|
session["appInstance"] = @appinstance.id
|
181
182
|
|
182
183
|
#We have multiple, user must pick
|
183
|
-
elsif appinstances.size > 1
|
184
|
+
elsif appinstances.size > 1
|
184
185
|
ZuoraConnect.logger.debug("User must select instance. #{@names}")
|
185
186
|
render "zuora_connect/static/launch", :locals => {:names => appinstances.to_h}
|
186
187
|
return
|
@@ -199,15 +200,15 @@ module ZuoraConnect
|
|
199
200
|
|
200
201
|
ActiveRecord::Base.transaction do
|
201
202
|
ActiveRecord::Base.connection.execute('LOCK public.zuora_users IN ACCESS EXCLUSIVE MODE')
|
202
|
-
|
203
|
-
|
203
|
+
sleep(2) #Sleep needed to wait for instance insertion
|
204
204
|
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)
|
205
205
|
if appinstances.size > 0
|
206
|
-
ZuoraConnect.logger.warn("Double tenant create for '#{zuora_client.rest_domain}' - '#{zuora_entity_id}'")
|
206
|
+
ZuoraConnect.logger.warn("Double tenant create for '#{zuora_client.rest_domain}' - '#{zuora_entity_id}' - '#{session["ZuoraCurrentIdentity"]["username"]}'")
|
207
207
|
redirect_to "https://#{zuora_host}/apps/newlogin.do?retURL=#{CGI.escape(request.fullpath)}"
|
208
208
|
return
|
209
209
|
end
|
210
210
|
|
211
|
+
next_id = (ZuoraConnect::AppInstance.all.where('id > 24999999').order(id: :desc).limit(1).pluck(:id).first || 24999999) + 1
|
211
212
|
user = (ENV['DEIS_APP'] || "Application").split('-').map(&:capitalize).join(' ')
|
212
213
|
body = {
|
213
214
|
'userId' => zuora_user_id,
|
@@ -215,7 +216,7 @@ module ZuoraConnect
|
|
215
216
|
'customAuthorities' => [],
|
216
217
|
'additionalInformation' => {
|
217
218
|
'description' => "This user is for #{user} application.",
|
218
|
-
'name' => "#{user} API User"
|
219
|
+
'name' => "#{user} API User #{next_id}"
|
219
220
|
}
|
220
221
|
}
|
221
222
|
|
@@ -228,12 +229,6 @@ module ZuoraConnect
|
|
228
229
|
client_describe = session["ZuoraCurrentUserInfo"]
|
229
230
|
end
|
230
231
|
|
231
|
-
Apartment::Tenant.switch!("public")
|
232
|
-
begin
|
233
|
-
Apartment::Tenant.create(next_id.to_s)
|
234
|
-
rescue Apartment::TenantExists => ex
|
235
|
-
ZuoraConnect.logger.debug("Tenant Already Exists")
|
236
|
-
end
|
237
232
|
available_entities = client_describe["accessibleEntities"].select {|entity| entity['id'] == client_describe['defaultEntityId']}
|
238
233
|
task_data = {
|
239
234
|
"id": next_id,
|
@@ -252,12 +247,36 @@ module ZuoraConnect
|
|
252
247
|
},
|
253
248
|
"tenant_ids": available_entities.map{|e| e['entityId'] }.push(client_describe["tenantId"]).uniq,
|
254
249
|
}
|
250
|
+
mapped_values = {:id => next_id, :api_token => rand(36**64).to_s(36), :token => rand(36**64).to_s(36), :zuora_logins => task_data, :oauth_expires_at => Time.now + 1000.years}
|
251
|
+
@appinstance = ZuoraConnect::AppInstance.new(mapped_values)
|
252
|
+
retry_count = 0
|
253
|
+
begin
|
254
|
+
@appinstance.save(:validate => false)
|
255
|
+
rescue ActiveRecord::RecordNotUnique => ex
|
256
|
+
if (retry_count += 1) < 3
|
257
|
+
@appinstance.assign_attributes({:api_token => rand(36**64).to_s(36), :token => rand(36**64).to_s(36)})
|
258
|
+
retry
|
259
|
+
else
|
260
|
+
Thread.current[:appinstance] = nil
|
261
|
+
session["appInstance"] = nil
|
262
|
+
render "zuora_connect/static/error_handled", :locals => {
|
263
|
+
:title => "Application could not create unique tokens.",
|
264
|
+
:message => "Please contact support or retry launching application."
|
265
|
+
}
|
266
|
+
return
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
255
270
|
|
256
|
-
|
257
|
-
|
258
|
-
@appinstance.
|
259
|
-
|
271
|
+
Apartment::Tenant.switch!("public")
|
272
|
+
begin
|
273
|
+
Apartment::Tenant.create(@appinstance.id.to_s)
|
274
|
+
rescue Apartment::TenantExists => ex
|
275
|
+
ZuoraConnect.logger.debug("Tenant Already Exists")
|
260
276
|
end
|
277
|
+
@appinstance.refresh
|
278
|
+
session["appInstance"] = @appinstance.id
|
279
|
+
|
261
280
|
rescue => ex
|
262
281
|
ZuoraConnect.logger.error(ex)
|
263
282
|
render "zuora_connect/static/error_unhandled", :locals => {:exception => ex}
|
@@ -301,11 +320,17 @@ module ZuoraConnect
|
|
301
320
|
PaperTrail.whodunnit = session["#{@appinstance.id}::user::email"] if defined?(PaperTrail)
|
302
321
|
end
|
303
322
|
begin
|
304
|
-
|
323
|
+
locale = session["#{@appinstance.id}::user::locale"]
|
324
|
+
I18n.locale = locale.present? ? locale : @appinstance.locale
|
305
325
|
rescue I18n::InvalidLocale => ex
|
306
326
|
ZuoraConnect.logger.error(ex) if !ZuoraConnect::AppInstance::IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
307
327
|
end
|
308
|
-
|
328
|
+
begin
|
329
|
+
Time.zone = session["#{@appinstance.id}::user::timezone"] ? session["#{@appinstance.id}::user::timezone"] : @appinstance.timezone
|
330
|
+
rescue
|
331
|
+
ZuoraConnect.logger.error(ex)
|
332
|
+
end
|
333
|
+
|
309
334
|
ZuoraConnect.logger.debug("[#{@appinstance.blank? ? "N/A" : @appinstance.id}] Authenticate App Request Completed In - #{(Time.now - start_time).round(2)}s")
|
310
335
|
end
|
311
336
|
|
@@ -356,6 +381,8 @@ module ZuoraConnect
|
|
356
381
|
ZuoraConnect.logger.debug({msg: 'Setup values', connect: values}) if Rails.env != "production"
|
357
382
|
|
358
383
|
@appinstance = ZuoraConnect::AppInstance.where(:id => values["appInstance"].to_i).first
|
384
|
+
|
385
|
+
mapped_values = {:api_token => values['api_token'], :token => values['api_token'], :access_token => values["access_token"], :refresh_token => values["refresh_token"], :oauth_expires_at => values["expires"]}
|
359
386
|
if @appinstance.blank?
|
360
387
|
Apartment::Tenant.switch!("public")
|
361
388
|
begin
|
@@ -363,13 +390,12 @@ module ZuoraConnect
|
|
363
390
|
rescue Apartment::TenantExists => ex
|
364
391
|
ZuoraConnect.logger.debug("Tenant Already Exists")
|
365
392
|
end
|
366
|
-
|
393
|
+
|
394
|
+
@appinstance = ZuoraConnect::AppInstance.new(mapped_values.merge({:id => values["appInstance"].to_i}))
|
367
395
|
@appinstance.save(:validate => false)
|
368
396
|
else
|
369
|
-
|
370
|
-
@appinstance.
|
371
|
-
@appinstance.oauth_expires_at = values["expires"] if !values["expires"].blank?
|
372
|
-
@appinstance.api_token = values["api_token"] if !values["api_token"].blank? && @appinstance.api_token != values["api_token"]
|
397
|
+
mapped_values.reject! {|key,value| [:api_token,:token].include?(key) && @appinstance[key].blank? }
|
398
|
+
@appinstance.assign_attributes(mapped_values)
|
373
399
|
if @appinstance.access_token_changed? && @appinstance.refresh_token_changed?
|
374
400
|
@appinstance.save(:validate => false)
|
375
401
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5q
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -333,6 +333,7 @@ files:
|
|
333
333
|
- db/migrate/20180301052853_add_catalog_attempted_at.rb
|
334
334
|
- db/migrate/20181206162339_add_fields_to_instance.rb
|
335
335
|
- db/migrate/20190520232221_add_zuora_user_table_and_alter_app_instance_id_table.rb
|
336
|
+
- db/migrate/20190520232222_add_unique_index.rb
|
336
337
|
- lib/logging/connect_formatter.rb
|
337
338
|
- lib/metrics/influx/point_value.rb
|
338
339
|
- lib/metrics/net.rb
|