zuora_connect 1.7.34 → 1.7.35

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
  SHA1:
3
- metadata.gz: 0db9c4ade0f13536864a0cda1feb9f83f60a2d51
4
- data.tar.gz: b6582466206b5e6ee3fc6985044cf63e22079dd1
3
+ metadata.gz: d8a219eafc3854e28ed2f7b5fa4f9c4e5068c817
4
+ data.tar.gz: f4dd332cf24735a5f58b226a852aad22096e85b1
5
5
  SHA512:
6
- metadata.gz: 7d1b60cc22ff13938b7fc0334f13e14d66a765b0ee29cbca006599474ef75d10a152451cef66b8584a0e78e54680883834a6adf2f31bf14ed99120695ff16c7f
7
- data.tar.gz: 473e3dea8f6ef996cb5caef766121ec143b2abc2903ba0005ff5c7c25684906bb5e10f2c77be343f3a750262e5ac2ef0021ec97043317075302cf1d3d1fae01e
6
+ metadata.gz: 99400c973cc4c4e98ab5d7f428ee32e91c495cd302f3c11352cef8c0717be13efd0187264749f6f77f4af6836260ccdf3420a84e11d1cc8d0dbe071a9abb47e0
7
+ data.tar.gz: 1f722cb14410348f844e708c5f6743d943135e3f59e42e6d5cf62f8e1b530c3d004e25193ff10e95a5518643a745a7881c1541fde9e05b29b067c3dea23b4d86
@@ -1,6 +1,6 @@
1
1
  module ZuoraConnect
2
2
  class StaticController < ApplicationController
3
- before_filter :authenticate_connect_app_request, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :launch, :switch, :initialize_app]
3
+ before_filter :authenticate_connect_app_request, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
4
4
  after_filter :persist_connect_app_session, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
5
5
  skip_before_filter :verify_authenticity_token, :only => [:initialize_app]
6
6
 
@@ -30,39 +30,6 @@ module ZuoraConnect
30
30
  }, status: 200
31
31
  end
32
32
 
33
- def launch
34
- @ids = JSON.parse(Base64.decode64(URI.decode(params["ids"])))
35
- if @ids.count == 1
36
- redirect_to :action => :switch, :commit => @ids[0][0]
37
- else
38
- respond_to do |format|
39
- format.html
40
- end
41
- end
42
- end
43
-
44
- def switch
45
- host = request.headers["HTTP_X_FORWARDED_HOST"]
46
- zuora_client = ZuoraAPI::Login.new(url: "https://#{host}")
47
- menus = zuora_client.get_full_nav(cookies.to_h)["menus"]
48
- menus = JSON.parse(response)["menus"]
49
- app = menus.select do |item|
50
- matches = /(?<=.com\/)(.*?)(?=\/|$)/.match(item["url"])
51
- if !matches.blank?
52
- matches[0] == ENV["DEIS_APP"]
53
- end
54
- end
55
- url_tasks = JSON.parse(Base64.decode64(URI.decode(URI.parse(app[0]["url"]).query.split("ids=")[1])))
56
- if url_tasks.map { |i| i[0] }.include?(params["commit"].to_i)
57
- @appinstance = ZuoraConnect::AppInstance.find(params["commit"].to_i)
58
- @appinstance.new_session(session: {})
59
- @appinstance.cache_app_instance
60
- redirect_to main_app.root_path
61
- else
62
- redirect_to main_app.root_path
63
- end
64
- end
65
-
66
33
  def initialize_app
67
34
  begin
68
35
  authenticate_connect_app_request
@@ -0,0 +1,65 @@
1
+ <html><head>
2
+ <title>We're sorry, but something went wrong (500)</title>
3
+ <meta name="viewport" content="width=device-width,initial-scale=1">
4
+ <style>
5
+ body {
6
+ background-color: #EFEFEF;
7
+ color: #2E2F30;
8
+ text-align: center;
9
+ font-family: arial, sans-serif;
10
+ margin: 0;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 95%;
15
+ max-width: 33em;
16
+ margin: 4em auto 0;
17
+ }
18
+
19
+ div.dialog > div {
20
+ border: 1px solid #CCC;
21
+ border-right-color: #999;
22
+ border-left-color: #999;
23
+ border-bottom-color: #BBB;
24
+ border-top: #B00100 solid 4px;
25
+ border-top-left-radius: 9px;
26
+ border-top-right-radius: 9px;
27
+ background-color: white;
28
+ padding: 7px 12% 0;
29
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
+ }
31
+
32
+ h1 {
33
+ font-size: 100%;
34
+ color: #730E15;
35
+ line-height: 1.5em;
36
+ }
37
+
38
+ div.dialog > p {
39
+ margin: 0 0 1em;
40
+ padding: 1em;
41
+ background-color: #F7F7F7;
42
+ border: 1px solid #CCC;
43
+ border-right-color: #999;
44
+ border-left-color: #999;
45
+ border-bottom-color: #999;
46
+ border-bottom-left-radius: 4px;
47
+ border-bottom-right-radius: 4px;
48
+ border-top-color: #DADADA;
49
+ color: #666;
50
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
51
+ }
52
+ </style>
53
+ </head>
54
+
55
+ <body>
56
+ <!-- This file lives in public/500.html -->
57
+ <div class="dialog">
58
+ <div>
59
+ <h1>The launch url was invalid.</h1>
60
+ </div>
61
+ <p>Please try relaunching this application</p>
62
+ </div>
63
+
64
+
65
+ </body></html>
@@ -38,7 +38,7 @@
38
38
  line-height: 1.5em;
39
39
  }
40
40
 
41
- input.submit {
41
+ div.button {
42
42
  margin: 1em 0 1em;
43
43
  padding: 1em;
44
44
  width: 300px;
@@ -66,11 +66,11 @@
66
66
  <h1>Please select the instance you would like to launch.</h1>
67
67
 
68
68
 
69
- <% @ids.each do |id| %>
70
- <%= form_tag({:controller => "static", :action => "switch"}, method: "post") do %>
71
-
72
- <%= submit_tag("#{id[0]} - #{id[1]}", :class => "submit")%>
73
- <% end %>
69
+ <% @app_instance_ids.each do |id| %>
70
+ <div class="button">
71
+ <% label = @names[id].present? ? "#{id} - #{@names[id]}" : id %>
72
+ <%= link_to label, root_path(app_instance_ids: params[:app_instance_ids], app_instance_id: id) %>
73
+ </div>
74
74
  <% end %>
75
75
  </div>
76
76
  </div>
data/config/routes.rb CHANGED
@@ -3,8 +3,6 @@ ZuoraConnect::Engine.routes.draw do
3
3
  get '/internal/data' => 'static#metrics'
4
4
  get '/invalid_session' => 'static#session_error', :as => :invalid_session
5
5
  get '/invalid_instance' => "static#invalid_app_instance_error", :as => :invalid_instance
6
- match '/hallway/launch' => 'static#launch', via: :get
7
- match '/hallway/switch' => 'static#switch', via: [:get, :post]
8
6
  post '/initialize_app' => 'static#initialize_app'
9
7
 
10
8
  namespace :api do
@@ -24,7 +24,89 @@ module ZuoraConnect
24
24
  Rails.logger.debug("[#{@appinstance.blank? ? "N/A" : @appinstance.id}] Authenticate App API Request Completed In - #{(Time.now - start_time).round(2)}s")
25
25
  end
26
26
 
27
+ def verify_with_navbar
28
+ if !session[params[:app_instance_ids]].present?
29
+ host = request.headers["HTTP_X_FORWARDED_HOST"]
30
+ zuora_client = ZuoraAPI::Login.new(url: "https://#{host}")
31
+ menus = zuora_client.get_full_nav(cookies.to_h)["menus"]
32
+ app = menus.select do |item|
33
+ matches = /(?<=.com\/)(.*?)(?=\/|$)/.match(item["url"])
34
+ if !matches.blank?
35
+ matches[0].split("?").first == ENV["DEIS_APP"]
36
+ end
37
+ end
38
+
39
+ session[params[:app_instance_ids]] = app[0]
40
+ return app[0]
41
+ else
42
+ return session[params[:app_instance_ids]]
43
+ end
44
+ end
45
+
46
+ def select_instance
47
+ begin
48
+ app = verify_with_navbar
49
+
50
+ url_tasks = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(app["url"]).query)["app_instance_ids"][0]))
51
+ @app_instance_ids = JSON.parse(Base64.urlsafe_decode64(params[:app_instance_ids]))
52
+
53
+ if (url_tasks & @app_instance_ids).size == @app_instance_ids.size
54
+ sql = "select name,id from zuora_connect_app_instances where id = ANY(ARRAY#{@app_instance_ids})"
55
+ result = ActiveRecord::Base.connection.execute(sql)
56
+ @names = {}
57
+ result.each do |x|
58
+ @names[x["id"].to_i] = x["name"]
59
+ end
60
+ render "zuora_connect/static/launch"
61
+ else
62
+ render "zuora_connect/static/invalid_launch_request"
63
+ end
64
+ rescue => ex
65
+ Rails.logger.debug("Error parsing Instance ID's: #{ex.message}")
66
+ render "zuora_connect/static/invalid_launch_request"
67
+ end
68
+ end
69
+
27
70
  def authenticate_connect_app_request
71
+ if params[:app_instance_ids].present? && !params[:app_instance_id].present?
72
+ begin
73
+ app_instance_ids = JSON.parse(Base64.urlsafe_decode64(params[:app_instance_ids]))
74
+ if app_instance_ids.length == 1
75
+ verify_with_navbar
76
+ instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
77
+ if instances.include?(app_instance_ids[0])
78
+ @appinstance = ZuoraConnect::AppInstance.find(app_instance_ids[0])
79
+ @appinstance.new_session(session: {})
80
+ @appinstance.cache_app_instance
81
+ else
82
+ render "zuora_connect/static/invalid_launch_request"
83
+ return
84
+ end
85
+ else
86
+ select_instance
87
+ return
88
+ end
89
+ rescue
90
+ render "zuora_connect/static/invalid_launch_request"
91
+ return
92
+ end
93
+
94
+ elsif params[:app_instance_ids].present? && params[:app_instance_id].present?
95
+ begin
96
+ instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
97
+ if instances.include?(params[:app_instance_id].to_i)
98
+ @appinstance = ZuoraConnect::AppInstance.find(params[app_instance_id].to_i)
99
+ @appinstance.new_session(session: {})
100
+ @appinstance.cache_app_instance
101
+ else
102
+ render "zuora_connect/static/invalid_launch_request"
103
+ return
104
+ end
105
+ rescue => ex
106
+ render "zuora_connect/static/invalid_launch_request"
107
+ return
108
+ end
109
+ end
28
110
  Thread.current[:appinstance] = nil
29
111
  start_time = Time.now
30
112
  if ZuoraConnect.configuration.mode == "Production"
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.7.34"
2
+ VERSION = "1.7.35"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.34
4
+ version: 1.7.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
@@ -264,6 +264,7 @@ files:
264
264
  - app/views/layouts/zuora_connect/application.html.erb
265
265
  - app/views/sql/refresh_aggregate_table.txt
266
266
  - app/views/zuora_connect/static/invalid_app_instance_error.html.erb
267
+ - app/views/zuora_connect/static/invalid_launch_request.html
267
268
  - app/views/zuora_connect/static/launch.html.erb
268
269
  - app/views/zuora_connect/static/session_error.html.erb
269
270
  - config/initializers/apartment.rb