zuora_connect 0.0.8.8 → 0.0.9.0

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: cb571a97d8681a301ca314a1d95f3549ccad57ba
4
- data.tar.gz: 7d2fe3929a59033b06e2fbc6e31b0cc192160eca
3
+ metadata.gz: 3437db532ebccdc345287d49824cd56424a9bc11
4
+ data.tar.gz: 757d62f6476b7ddf9d363ea7d9f40a43a34f84f2
5
5
  SHA512:
6
- metadata.gz: cbbea8478bfe96f32c74774b472abf0f558ea3eacd1653ba39307f7f0b6371598fdf6a2b22466c242ad1d9301f2651fb62e836b419346f26160a6036098e64e9
7
- data.tar.gz: b7180a6de4307a4dd42b167e0703da65fe60e444be0bb260216485515d77b1216d58025fbc22c95a420f698cd32ebdce0e01d4b5de299daf5e9b32bbbf94fc5f
6
+ metadata.gz: 1a52d807193b0de7a24876a746f4ca29242e60f29cb2eb67a71d0da5b2f484b8c0282f285a9f4ff936f1a7466d72e213516919390d636d669d23e7dce57294aa
7
+ data.tar.gz: 2a2a4605e65b9b401962cc6073375b758ae9145c3e3b7afe8c9c63cc7883128494279a56d0c16ef8f3229a7ba63528c30b192ebe67e8e5e67f88834fdbbb69e6
@@ -1,6 +1,8 @@
1
1
  module ZuoraConnect
2
2
  class AppInstance < ActiveRecord::Base
3
3
  after_initialize :init
4
+ before_create :generate_access_token
5
+ validates :token, :uniqueness => true
4
6
  attr_accessor :options, :mode, :logins, :valid, :task_data, :last_refresh, :username, :password
5
7
 
6
8
  def init
@@ -100,5 +102,12 @@ module ZuoraConnect
100
102
  singleton_class.class_eval { attr_accessor "#{field}" }
101
103
  send("#{field}=", val)
102
104
  end
105
+
106
+ def generate_access_token
107
+ begin
108
+ self.token = SecureRandom.hex
109
+ end while self.class.exists?(token: token)
110
+ end
111
+
103
112
  end
104
113
  end
@@ -0,0 +1,5 @@
1
+ class AddTokenToAppInstance < ActiveRecord::Migration
2
+ def change
3
+ add_column :zuora_connect_app_instances, :token, :string
4
+ end
5
+ end
@@ -10,9 +10,14 @@ module ZuoraConnect
10
10
 
11
11
  def authenticate_app_api_request
12
12
  authenticate_or_request_with_http_basic do |username, password|
13
- @appinstance = ZuoraConnect::AppInstance.find(params[:instance_id])
14
- @appinstance.new_session(:session => {}, :username => username, :password => password)
15
- return @appinstance.valid
13
+ @appinstance = ZuoraConnect::AppInstance.where(:token => password).first
14
+ if !@appinstance.blank?
15
+ @appinstance.new_session(:session => {})
16
+ Thread.current[:appinstance] = @appinstance
17
+ return @appinstance.valid
18
+ else
19
+ return false
20
+ end
16
21
  end
17
22
  end
18
23
 
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "0.0.8.8"
2
+ VERSION = "0.0.9.0"
3
3
  end
@@ -2,7 +2,7 @@ module ZuoraConnect
2
2
  module Views
3
3
  module Helpers
4
4
  def is_app_admin?
5
- return session["#{@appinstance.id}::admin"]
5
+ return @appinstance.blank? ? false : session["#{@appinstance.id}::admin"]
6
6
  end
7
7
  end
8
8
  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: 0.0.8.8
4
+ version: 0.0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
@@ -128,6 +128,7 @@ files:
128
128
  - config/routes.rb
129
129
  - db/migrate/20160718151733_create_connect_app_instances.rb
130
130
  - db/migrate/20161024162319_add_tokens_to_app_instance.rb
131
+ - db/migrate/20161024220705_add_token_to_app_instance.rb
131
132
  - lib/tasks/zuora_connect_tasks.rake
132
133
  - lib/zuora_connect.rb
133
134
  - lib/zuora_connect/configuration.rb