shopify_app 6.1.2 → 6.1.3

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: edd2018df13585de884dcef3250e27251cba681c
4
- data.tar.gz: 0297fb447782e9268f3af28fdede9d30b777f0a5
3
+ metadata.gz: ad89b235fe52fa742244b8b41e4cd54c892c7756
4
+ data.tar.gz: 1444bd3ab1ce8fa75307adf0f079b12f2e9cad39
5
5
  SHA512:
6
- metadata.gz: b52906367f75755913a17b5659d6cb782850386f7e4b23c601a24afb50bddab5e0132f5af93ba8c2a79d052d65cf403fcf228f84873b8ca7b7d475d0aae1328b
7
- data.tar.gz: 5be95c420bb9a8585e764ced63d38048401a922b2cd1c436d5b0f272318a3ab90a2f1c8caca5e3b70167b1146cc1290fdbb35216d88c9c66c3122ed6b9557e0a
6
+ metadata.gz: 802e2f111acf873666e658054dba37263b5f604aadc218d3f56708459c87435a02ea62445a2a1525179706d10c3811577febafd4c83d6613a80d15f9513f409b
7
+ data.tar.gz: 0934008dbe28d8bd66170a7ee112e0b60d8bc9e4dd8e9d7ef3de74d925bb4eed39bf0807c76eea77644777fda920977b884e8f0a53e6a1cbc8191044bc40de11
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ doc/
8
8
  *.log
9
9
  *.sqlite3
10
10
  test/tmp/*
11
+ .idea
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 6.1.3
2
+ -----
3
+ * add redirect_uri which is now required
4
+ * fix login again with different shop
5
+
1
6
  6.0.0
2
7
  -----
3
8
  * Re-written as a proper rails engine
data/README.md CHANGED
@@ -57,7 +57,7 @@ $ rails generate shopify_app:install
57
57
 
58
58
  # or optionally with arguments:
59
59
 
60
- $ rails generate shopify_app:install -api_key=<your_api_key> -secret=<your_app_secret>
60
+ $ rails generate shopify_app:install -api_key=<your_api_key> -secret=<your_app_secret> -redirect_uri=<your_redirect_uri>
61
61
  ```
62
62
 
63
63
  Other options include:
@@ -101,6 +101,7 @@ The `install` generator places your Api credentials directly into the shopify_ap
101
101
  ShopifyApp.configure do |config|
102
102
  config.api_key = ENV['SHOPIFY_CLIENT_API_KEY']
103
103
  config.secret = ENV['SHOPIFY_CLIENT_API_SECRET']
104
+ config.redirect_uri = "<%= your_redirect_uri %>"
104
105
  config.scope = 'read_customers, read_orders, write_products'
105
106
  config.embedded_app = true
106
107
  end
@@ -19,6 +19,7 @@ module ShopifyApp
19
19
  {
20
20
  api_key: '<api_key>',
21
21
  secret: '<secret>',
22
+ redirect_uri: '<redirect_uri>',
22
23
  scope: 'read_orders, read_products',
23
24
  embedded: 'true'
24
25
  }
@@ -7,7 +7,8 @@
7
7
  <script type="text/javascript">
8
8
  ShopifyApp.init({
9
9
  apiKey: "<%= ShopifyApp.configuration.api_key %>",
10
- shopOrigin: '<%= "https://#{ @shop_session.url }" if @shop_session %>'
10
+ shopOrigin: "<%= "https://#{ @shop_session.url }" if @shop_session %>",
11
+ debug: <%= Rails.env.development? ? 'true' : 'false' %>
11
12
  });
12
13
  </script>
13
14
 
@@ -1,6 +1,7 @@
1
1
  ShopifyApp.configure do |config|
2
2
  config.api_key = "<%= opts[:api_key] %>"
3
3
  config.secret = "<%= opts[:secret] %>"
4
+ config.redirect_uri = "<%= opts[:redirect_uri] %>"
4
5
  config.scope = "<%= opts[:scope] %>"
5
6
  config.embedded_app = <%= embedded_app? %>
6
7
  end
@@ -2,4 +2,6 @@
2
2
  ShopifyApp.configuration.api_key,
3
3
  ShopifyApp.configuration.secret,
4
4
 
5
+ :redirect_uri => ShopifyApp.configuration.redirect_uri,
6
+
5
7
  :scope => ShopifyApp.configuration.scope
@@ -6,6 +6,7 @@ module ShopifyApp
6
6
  # `config/initializers/shopify_app.rb`
7
7
  attr_accessor :api_key
8
8
  attr_accessor :secret
9
+ attr_accessor :redirect_uri
9
10
  attr_accessor :scope
10
11
  attr_accessor :embedded_app
11
12
  alias_method :embedded_app?, :embedded_app
@@ -26,6 +26,8 @@ module ShopifyApp
26
26
 
27
27
  def login_again_if_different_shop
28
28
  if shop_session && params[:shop] && params[:shop].is_a?(String) && shop_session.url != params[:shop]
29
+ session[:shopify] = nil
30
+ session[:shopify_domain] = nil
29
31
  redirect_to_login
30
32
  end
31
33
  end
@@ -39,6 +41,7 @@ module ShopifyApp
39
41
 
40
42
  def close_session
41
43
  session[:shopify] = nil
44
+ session[:shopify_domain] = nil
42
45
  redirect_to login_path
43
46
  end
44
47
 
@@ -42,7 +42,7 @@ module ShopifyApp
42
42
  end
43
43
 
44
44
  def return_address
45
- session[:return_to] || main_app.root_url
45
+ session.delete(:return_to) || main_app.root_url
46
46
  end
47
47
 
48
48
  def sanitized_shop_name
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = "6.1.2"
2
+ VERSION = "6.1.3"
3
3
  end
@@ -17,6 +17,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
17
17
  assert_file "config/initializers/shopify_app.rb" do |shopify_app|
18
18
  assert_match 'config.api_key = "<api_key>"', shopify_app
19
19
  assert_match 'config.secret = "<secret>"', shopify_app
20
+ assert_match 'config.redirect_uri = "<redirect_uri>"', shopify_app
20
21
  assert_match 'config.scope = "read_orders, read_products"', shopify_app
21
22
  assert_match "config.embedded_app = true", shopify_app
22
23
  end
@@ -6,9 +6,15 @@ class LoginProtectionController < ActionController::Base
6
6
  include ShopifyApp::LoginProtection
7
7
  helper_method :shop_session
8
8
 
9
+ before_action :login_again_if_different_shop, only: [:second_login]
10
+
9
11
  def index
10
12
  render nothing: true
11
13
  end
14
+
15
+ def second_login
16
+ render nothing: true
17
+ end
12
18
  end
13
19
 
14
20
  class LoginProtectionTest < ActionController::TestCase
@@ -45,12 +51,26 @@ class LoginProtectionTest < ActionController::TestCase
45
51
  end
46
52
  end
47
53
 
54
+ test "login_again_if_different_shop removes current session and redirects to login path" do
55
+ with_application_test_routes do
56
+ session[:shopify] = "foobar"
57
+ session[:shopify_domain] = "foobar"
58
+ sess = stub(url: 'https://foobar.myshopify.com')
59
+ ShopifyApp::SessionRepository.expects(:retrieve).returns(sess).once
60
+ get :second_login, shop: 'other_shop'
61
+ assert_redirected_to @controller.send(:login_path, shop: 'other_shop')
62
+ assert_nil session[:shopify]
63
+ assert_nil session[:shopify_domain]
64
+ end
65
+ end
66
+
48
67
  private
49
68
 
50
69
  def with_application_test_routes
51
70
  with_routing do |set|
52
71
  set.draw do
53
72
  get '/' => 'login_protection#index'
73
+ get '/second_login' => 'login_protection#second_login'
54
74
  end
55
75
  yield
56
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.2
4
+ version: 6.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails