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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG +5 -0
- data/README.md +2 -1
- data/lib/generators/shopify_app/install/install_generator.rb +1 -0
- data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +2 -1
- data/lib/generators/shopify_app/install/templates/shopify_app.rb +1 -0
- data/lib/generators/shopify_app/install/templates/shopify_provider.rb +2 -0
- data/lib/shopify_app/configuration.rb +1 -0
- data/lib/shopify_app/login_protection.rb +3 -0
- data/lib/shopify_app/sessions_controller.rb +1 -1
- data/lib/shopify_app/version.rb +1 -1
- data/test/generators/install_generator_test.rb +1 -0
- data/test/shopify_app/login_protection_test.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad89b235fe52fa742244b8b41e4cd54c892c7756
|
4
|
+
data.tar.gz: 1444bd3ab1ce8fa75307adf0f079b12f2e9cad39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 802e2f111acf873666e658054dba37263b5f604aadc218d3f56708459c87435a02ea62445a2a1525179706d10c3811577febafd4c83d6613a80d15f9513f409b
|
7
|
+
data.tar.gz: 0934008dbe28d8bd66170a7ee112e0b60d8bc9e4dd8e9d7ef3de74d925bb4eed39bf0807c76eea77644777fda920977b884e8f0a53e6a1cbc8191044bc40de11
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
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
|
@@ -7,7 +7,8 @@
|
|
7
7
|
<script type="text/javascript">
|
8
8
|
ShopifyApp.init({
|
9
9
|
apiKey: "<%= ShopifyApp.configuration.api_key %>",
|
10
|
-
shopOrigin:
|
10
|
+
shopOrigin: "<%= "https://#{ @shop_session.url }" if @shop_session %>",
|
11
|
+
debug: <%= Rails.env.development? ? 'true' : 'false' %>
|
11
12
|
});
|
12
13
|
</script>
|
13
14
|
|
@@ -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
|
|
data/lib/shopify_app/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|