shopify_app 8.2.5 → 8.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/app/assets/javascripts/shopify_app/redirect.js +19 -0
- data/app/controllers/shopify_app/sessions_controller.rb +1 -1
- data/app/views/shopify_app/sessions/new.html.erb +3 -3
- data/app/views/shopify_app/shared/redirect.html.erb +22 -0
- data/docs/Quickstart.md +26 -23
- data/lib/generators/shopify_app/install/install_generator.rb +0 -1
- data/lib/generators/shopify_app/install/templates/_flash_messages.html.erb +11 -9
- data/lib/shopify_app/controller_concerns/login_protection.rb +13 -37
- data/lib/shopify_app/engine.rb +4 -0
- data/lib/shopify_app/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2646af06c48a37cfbb95b06b993a766bb71ee40
|
4
|
+
data.tar.gz: b5180bafe5d1a2dff0b504cc88d88dd2591b4ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f316a0447cb5bdcc47be2186183104b42767232e11eb3538b576479567fc930dfb24e17d911a1d1c6b5b5d56c6ffabf5e0b8891946b1f0b2506eefb0373dbf51
|
7
|
+
data.tar.gz: 10bfeabacdee5645f6d1ee04177aeefb893ec25a7ea505f564a2ed04f28abdb03e81d8796e9a5859505a8bf1458e43a4154f47d371a27b1da148cb3823925b2a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -54,7 +54,7 @@ Quickstart
|
|
54
54
|
|
55
55
|
Check out this screencast on how to create and deploy a new Shopify App to Heroku in 5 minutes:
|
56
56
|
|
57
|
-
[https://
|
57
|
+
[https://www.youtube.com/watch?v=yGxeoAHlQOg](https://www.youtube.com/watch?v=yGxeoAHlQOg)
|
58
58
|
|
59
59
|
Or if you prefer text instructions the steps in the video are written out [here](https://github.com/Shopify/shopify_app/blob/master/docs/Quickstart.md)
|
60
60
|
|
@@ -367,7 +367,7 @@ If you only run the install generator then by default you will have an in memory
|
|
367
367
|
AuthenticatedController
|
368
368
|
-----------------------
|
369
369
|
|
370
|
-
The engine includes a controller called `ShopifyApp::AuthenticatedController` which inherits from `
|
370
|
+
The engine includes a controller called `ShopifyApp::AuthenticatedController` which inherits from `ActionController::Base`. It adds some before_filters which ensure the user is authenticated and will redirect to the login page if not. It is best practice to have all controllers that belong to the Shopify part of your app inherit from this controller. The HomeController that is generated already inherits from AuthenticatedController.
|
371
371
|
|
372
372
|
AppProxyVerification
|
373
373
|
--------------------
|
@@ -0,0 +1,19 @@
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function() {
|
2
|
+
var redirectTargetElement = document.getElementById("redirection-target");
|
3
|
+
var targetInfo = JSON.parse(redirectTargetElement.dataset.target)
|
4
|
+
|
5
|
+
if (window.top == window.self) {
|
6
|
+
// If the current window is the 'parent', change the URL by setting location.href
|
7
|
+
window.top.location.href = targetInfo.url;
|
8
|
+
} else {
|
9
|
+
// If the current window is the 'child', change the parent's URL with postMessage
|
10
|
+
normalizedLink = document.createElement('a');
|
11
|
+
normalizedLink.href = targetInfo.url;
|
12
|
+
|
13
|
+
data = JSON.stringify({
|
14
|
+
message: 'Shopify.API.remoteRedirect',
|
15
|
+
data: { location: normalizedLink.href }
|
16
|
+
});
|
17
|
+
window.parent.postMessage(data, targetInfo.myshopifyUrl);
|
18
|
+
}
|
19
|
+
});
|
@@ -2,7 +2,7 @@ module ShopifyApp
|
|
2
2
|
class SessionsController < ActionController::Base
|
3
3
|
include ShopifyApp::LoginProtection
|
4
4
|
layout false, only: :new
|
5
|
-
after_action only: :new do |controller|
|
5
|
+
after_action only: [:new, :create] do |controller|
|
6
6
|
controller.response.headers.except!('X-Frame-Options')
|
7
7
|
end
|
8
8
|
|
@@ -110,13 +110,13 @@
|
|
110
110
|
<label for="shop">Enter your shop domain to log in or install this app.</label>
|
111
111
|
</p>
|
112
112
|
|
113
|
-
|
113
|
+
<%= form_tag login_path do %>
|
114
114
|
<% if flash[:error] %>
|
115
|
-
<div class=error><%= flash[:error] %></div>
|
115
|
+
<div class="error"><%= flash[:error] %></div>
|
116
116
|
<% end %>
|
117
117
|
<input id="shop" name="shop" type="text" autofocus="autofocus" placeholder="example.myshopify.com" class="marketing-input">
|
118
118
|
<button type="submit" class="marketing-button">Install</button>
|
119
|
-
|
119
|
+
<% end %>
|
120
120
|
</main>
|
121
121
|
|
122
122
|
</body>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<base target="_top">
|
6
|
+
<title>Redirecting…</title>
|
7
|
+
<%= javascript_include_tag('shopify_app/redirect', crossorigin: 'anonymous', integrity: true) %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%=
|
11
|
+
content_tag(:div, nil,
|
12
|
+
id: 'redirection-target',
|
13
|
+
data: {
|
14
|
+
target: {
|
15
|
+
myshopifyUrl: "https://#{current_shopify_domain}",
|
16
|
+
url: url,
|
17
|
+
},
|
18
|
+
},
|
19
|
+
)
|
20
|
+
%>
|
21
|
+
</body>
|
22
|
+
</html>
|
data/docs/Quickstart.md
CHANGED
@@ -6,12 +6,12 @@ Build and deploy a new Shopify App to Heroku in minutes
|
|
6
6
|
1. New Rails App (with postgres)
|
7
7
|
--------------------------------
|
8
8
|
|
9
|
-
```
|
10
|
-
rails new test-app --database=postgresql
|
11
|
-
cd test-app
|
12
|
-
git init
|
13
|
-
git add .
|
14
|
-
git commit -m 'new rails app'
|
9
|
+
```sh
|
10
|
+
$ rails new test-app --database=postgresql
|
11
|
+
$ cd test-app
|
12
|
+
$ git init
|
13
|
+
$ git add .
|
14
|
+
$ git commit -m 'new rails app'
|
15
15
|
```
|
16
16
|
|
17
17
|
2. Create a new Heroku app
|
@@ -20,17 +20,17 @@ git commit -m 'new rails app'
|
|
20
20
|
The next step is to create a new heroku app. Pull up your heroku dashboard and make a new app!
|
21
21
|
|
22
22
|
cli:
|
23
|
+
```sh
|
24
|
+
$ heroku create name
|
25
|
+
$ heroku git:remote -a name
|
23
26
|
```
|
24
|
-
heroku create name
|
25
|
-
heroku git:remote -a name
|
26
|
-
```
|
27
27
|
|
28
28
|
now we need to let git know where the remote server is so we'll be able to deploy later
|
29
29
|
|
30
30
|
web:
|
31
|
-
```
|
32
|
-
https://dashboard.heroku.com/new
|
33
|
-
git remote add heroku git@heroku.com:appinfive.git
|
31
|
+
```sh
|
32
|
+
# https://dashboard.heroku.com/new
|
33
|
+
$ git remote add heroku git@heroku.com:appinfive.git
|
34
34
|
```
|
35
35
|
|
36
36
|
3. Create a new App in the partners area
|
@@ -43,28 +43,31 @@ git remote add heroku git@heroku.com:appinfive.git
|
|
43
43
|
|
44
44
|
4. Add ShopifyApp to gemfile
|
45
45
|
----------------------------
|
46
|
-
```
|
46
|
+
```sh
|
47
47
|
$ echo "gem 'shopify_app'" >> Gemfile
|
48
|
-
|
49
|
-
bundle install
|
48
|
+
$ bundle install
|
50
49
|
```
|
51
50
|
|
52
51
|
Note - its recommended to use the latest released version. Check the git tags to see the latest release and then add it to your Gemfile e.g `gem 'shopify_app', '~> 7.0.0'`
|
53
52
|
|
54
53
|
5. Run the ShopifyApp generator
|
55
54
|
-------------------------------
|
55
|
+
```sh
|
56
|
+
# use the keys from your app in the partners area
|
57
|
+
$ rails generate shopify_app --api_key <shopify_api_key> --secret <shopify_api_secret>
|
58
|
+
$ git add .
|
59
|
+
$ git commit -m 'generated shopify app'
|
56
60
|
```
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
```
|
61
|
+
|
62
|
+
If you forget to set your keys or redirect uri above, you will find them in the shopify_app initializer at: `/config/initializers/shopify_app.rb`.
|
63
|
+
|
64
|
+
We recommend adding a gem or utilizing ENV variables to handle your keys before releasing your app.
|
62
65
|
|
63
66
|
6. Deploy
|
64
67
|
---------
|
65
|
-
```
|
66
|
-
git push heroku
|
67
|
-
heroku run rake db:migrate
|
68
|
+
```sh
|
69
|
+
$ git push heroku
|
70
|
+
$ heroku run rake db:migrate
|
68
71
|
```
|
69
72
|
|
70
73
|
7. Install the App!
|
@@ -2,16 +2,18 @@
|
|
2
2
|
<script type="text/javascript">
|
3
3
|
var eventName = typeof(Turbolinks) !== 'undefined' ? 'turbolinks:load' : 'DOMContentLoaded';
|
4
4
|
|
5
|
-
document.
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
if (!document.documentElement.hasAttribute("data-turbolinks-preview")) {
|
6
|
+
document.addEventListener(eventName, function flash() {
|
7
|
+
<% if flash[:notice] %>
|
8
|
+
ShopifyApp.flashNotice("<%= j flash[:notice].html_safe %>");
|
9
|
+
<% end %>
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
<% if flash[:error] %>
|
12
|
+
ShopifyApp.flashError("<%= j flash[:error].html_safe %>");
|
13
|
+
<% end %>
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
document.removeEventListener(eventName, flash)
|
16
|
+
});
|
17
|
+
}
|
16
18
|
</script>
|
17
19
|
<% end %>
|
@@ -40,7 +40,9 @@ module ShopifyApp
|
|
40
40
|
if request.xhr?
|
41
41
|
head :unauthorized
|
42
42
|
else
|
43
|
-
|
43
|
+
if request.get?
|
44
|
+
session[:return_to] = "#{request.path}?#{sanitized_params.to_query}"
|
45
|
+
end
|
44
46
|
redirect_to login_url
|
45
47
|
end
|
46
48
|
end
|
@@ -55,7 +57,7 @@ module ShopifyApp
|
|
55
57
|
url = ShopifyApp.configuration.login_url
|
56
58
|
|
57
59
|
if params[:shop].present?
|
58
|
-
query = { shop:
|
60
|
+
query = { shop: sanitized_params[:shop] }.to_query
|
59
61
|
url = "#{url}?#{query}"
|
60
62
|
end
|
61
63
|
|
@@ -64,46 +66,12 @@ module ShopifyApp
|
|
64
66
|
|
65
67
|
def fullpage_redirect_to(url)
|
66
68
|
if ShopifyApp.configuration.embedded_app?
|
67
|
-
render
|
69
|
+
render 'shopify_app/shared/redirect', locals: { url: url, current_shopify_domain: current_shopify_domain }
|
68
70
|
else
|
69
71
|
redirect_to url
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
def redirection_javascript(url)
|
74
|
-
%(
|
75
|
-
<!DOCTYPE html>
|
76
|
-
<html lang="en">
|
77
|
-
<head>
|
78
|
-
<meta charset="utf-8" />
|
79
|
-
<base target="_top">
|
80
|
-
<title>Redirecting…</title>
|
81
|
-
<script type="text/javascript">
|
82
|
-
|
83
|
-
// If the current window is the 'parent', change the URL by setting location.href
|
84
|
-
if (window.top == window.self) {
|
85
|
-
window.top.location.href = #{url.to_json};
|
86
|
-
|
87
|
-
// If the current window is the 'child', change the parent's URL with postMessage
|
88
|
-
} else {
|
89
|
-
normalizedLink = document.createElement('a');
|
90
|
-
normalizedLink.href = #{url.to_json};
|
91
|
-
|
92
|
-
data = JSON.stringify({
|
93
|
-
message: 'Shopify.API.remoteRedirect',
|
94
|
-
data: { location: normalizedLink.href }
|
95
|
-
});
|
96
|
-
window.parent.postMessage(data, "https://#{current_shopify_domain}");
|
97
|
-
}
|
98
|
-
|
99
|
-
</script>
|
100
|
-
</head>
|
101
|
-
<body>
|
102
|
-
</body>
|
103
|
-
</html>
|
104
|
-
)
|
105
|
-
end
|
106
|
-
|
107
75
|
def current_shopify_domain
|
108
76
|
shopify_domain = sanitized_shop_name || session[:shopify_domain]
|
109
77
|
return shopify_domain if shopify_domain.present?
|
@@ -119,5 +87,13 @@ module ShopifyApp
|
|
119
87
|
return unless params[:shop].present?
|
120
88
|
ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
|
121
89
|
end
|
90
|
+
|
91
|
+
def sanitized_params
|
92
|
+
request.query_parameters.clone.tap do |query_params|
|
93
|
+
if params[:shop].is_a?(String)
|
94
|
+
query_params[:shop] = sanitize_shop_param(params)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
122
98
|
end
|
123
99
|
end
|
data/lib/shopify_app/engine.rb
CHANGED
data/lib/shopify_app/version.rb
CHANGED
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: 8.2.
|
4
|
+
version: 8.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -136,10 +136,12 @@ files:
|
|
136
136
|
- LICENSE
|
137
137
|
- README.md
|
138
138
|
- Rakefile
|
139
|
+
- app/assets/javascripts/shopify_app/redirect.js
|
139
140
|
- app/controllers/shopify_app/authenticated_controller.rb
|
140
141
|
- app/controllers/shopify_app/sessions_controller.rb
|
141
142
|
- app/controllers/shopify_app/webhooks_controller.rb
|
142
143
|
- app/views/shopify_app/sessions/new.html.erb
|
144
|
+
- app/views/shopify_app/shared/redirect.html.erb
|
143
145
|
- config/locales/de.yml
|
144
146
|
- config/locales/en.yml
|
145
147
|
- config/locales/es.yml
|
@@ -215,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
217
|
version: '0'
|
216
218
|
requirements: []
|
217
219
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.
|
220
|
+
rubygems_version: 2.6.14
|
219
221
|
signing_key:
|
220
222
|
specification_version: 4
|
221
223
|
summary: This gem is used to get quickly started with the Shopify API
|