shopify_app 6.4.2 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/ISSUE_TEMPLATE.md +14 -0
  4. data/QUICKSTART.md +6 -7
  5. data/README.md +38 -16
  6. data/Rakefile +2 -6
  7. data/app/controllers/shopify_app/authenticated_controller.rb +7 -0
  8. data/app/controllers/shopify_app/sessions_controller.rb +5 -0
  9. data/app/controllers/shopify_app/webhooks_controller.rb +27 -0
  10. data/app/views/{sessions → shopify_app/sessions}/new.html.erb +0 -0
  11. data/config/routes.rb +4 -0
  12. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +61 -0
  13. data/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb +8 -0
  14. data/lib/generators/shopify_app/controllers/controllers_generator.rb +1 -1
  15. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +0 -1
  16. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +1 -1
  17. data/lib/generators/shopify_app/install/install_generator.rb +13 -19
  18. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +2 -2
  19. data/lib/generators/shopify_app/install/templates/shopify_app.rb +3 -4
  20. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +0 -1
  21. data/lib/generators/shopify_app/routes/templates/routes.rb +4 -0
  22. data/lib/generators/shopify_app/shopify_app_generator.rb +1 -7
  23. data/lib/shopify_app.rb +2 -3
  24. data/lib/shopify_app/configuration.rb +0 -1
  25. data/lib/shopify_app/engine.rb +1 -0
  26. data/lib/shopify_app/login_protection.rb +53 -5
  27. data/lib/shopify_app/{sessions_controller.rb → sessions_concern.rb} +5 -5
  28. data/lib/shopify_app/version.rb +1 -1
  29. data/lib/shopify_app/webhook_verification.rb +35 -0
  30. data/shopify_app.gemspec +1 -1
  31. metadata +11 -43
  32. data/CONTRIBUTING.md +0 -14
  33. data/app/controllers/authenticated_controller.rb +0 -5
  34. data/app/controllers/sessions_controller.rb +0 -3
  35. data/lib/shopify_app/controller.rb +0 -18
  36. data/lib/shopify_app/webhooks_controller.rb +0 -35
  37. data/test/app_templates/app/controllers/application_controller.rb +0 -2
  38. data/test/app_templates/config/application.rb +0 -24
  39. data/test/app_templates/config/initializers/shopify_app.rb +0 -6
  40. data/test/app_templates/config/routes.rb +0 -4
  41. data/test/controllers/sessions_controller_test.rb +0 -122
  42. data/test/controllers/sessions_routes_test.rb +0 -27
  43. data/test/dummy/Rakefile +0 -6
  44. data/test/dummy/app/controllers/application_controller.rb +0 -3
  45. data/test/dummy/app/controllers/home_controller.rb +0 -7
  46. data/test/dummy/config.ru +0 -4
  47. data/test/dummy/config/application.rb +0 -26
  48. data/test/dummy/config/boot.rb +0 -5
  49. data/test/dummy/config/database.yml +0 -25
  50. data/test/dummy/config/environment.rb +0 -5
  51. data/test/dummy/config/environments/test.rb +0 -42
  52. data/test/dummy/config/initializers/shopify_app.rb +0 -6
  53. data/test/dummy/config/routes.rb +0 -10
  54. data/test/dummy/config/secrets.yml +0 -17
  55. data/test/generators/controllers_generator_test.rb +0 -16
  56. data/test/generators/home_controller_generator_test.rb +0 -50
  57. data/test/generators/install_generator_test.rb +0 -87
  58. data/test/generators/routes_generator_test.rb +0 -26
  59. data/test/generators/shop_model_generator_test.rb +0 -39
  60. data/test/generators/shopify_app_generator.rb +0 -15
  61. data/test/generators/views_generator_test.rb +0 -15
  62. data/test/shopify_app/configuration_test.rb +0 -49
  63. data/test/shopify_app/in_memory_session_store_test.rb +0 -35
  64. data/test/shopify_app/login_protection_test.rb +0 -100
  65. data/test/shopify_app/shopify_session_repository_test.rb +0 -73
  66. data/test/shopify_app/utils_test.rb +0 -30
  67. data/test/shopify_app/webhooks_controller_test.rb +0 -50
  68. data/test/shopify_app/webhooks_manager_test.rb +0 -86
  69. data/test/support/generator_test_helpers.rb +0 -29
  70. data/test/test_helper.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf9c3e006763978a94a3a0ebf25ad30ba50c837f
4
- data.tar.gz: 4a980dc3eb13651e9fd50470ce7fb8ae31efd90c
3
+ metadata.gz: b6ad0f2e17e02639259c5664e451a46bb524e304
4
+ data.tar.gz: 7cc21860a23e3d3f9bc21dfe90782dac008354c6
5
5
  SHA512:
6
- metadata.gz: b2047b5db8cc3c91cc02b24bbf381ce3b76f82f07564958595936684cf0093e1212a78b9fb721a2e4847b122e69e101a1b3f03e8ebb6800aa0e482c27010c3e5
7
- data.tar.gz: 2a87354cc1f99c3bee2a8836979ef7e1e660cfd6a723279cae45c191f3f94c567cdf8ba74d3af645c955513a8c54bcb823b206c35a797898536acc1d07150989
6
+ metadata.gz: ce081c615bd1d21b213c27cdd3b62ac3fd7f8200aa1aa20204222b0616d741e4af52c535a73c954a93fb3d0c8ed581a34588be8b90306b143b1a04d8f9c2f4cd
7
+ data.tar.gz: 816f9259c2e32e8a39749f26d3c031839e88a1d0f57f0393a3013820a8a23916331dc6793e2d859b9be11ea8cfdc2467e6bca06469f8803ef8e0e296832ddce5
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ 7.0.0
2
+ ----------
3
+
4
+ * rename WebhooksController module to WebhookVerification
5
+ * added a WebhooksController which automatically delegates to jobs
6
+ * moved all engine controllers under the ShopifyApp namespace
7
+ * rename SessionsController module to SessionsConcern
8
+ * more robust redirects, with valid HTML in HTTP response bodies
9
+ * `ShopifyApp::Controller` has been removed. You’ll need to replace all includes of `ShopifyApp::Controller` with `ShopifyApp::LoginProtection`
10
+ * adds add_webhook generator to make it easier to add new webhooks to your app
11
+ * update the install generator to use standard rails generate arguments, usage has changed from `-api_key=your_key` to `--api_key your_key`
12
+ * remove the redirect uri - this is done automatically inside omniauth now
13
+
1
14
  6.4.2
2
15
  -----
3
16
 
@@ -0,0 +1,14 @@
1
+ Submitting Issues
2
+ -----------------
3
+
4
+ Please open an issue here if you encounter a specific bug with this gem or the generators
5
+
6
+ General questions about the Shopify API should be posted on the [Shopify forums](https://ecommerce.shopify.com/c/shopify-apis-and-technology).
7
+
8
+
9
+ Authentication Issues
10
+ ---------------------
11
+
12
+ A great deal of the issues surrounding this repo are around authenticating (installing) the generated app with Shopify.
13
+
14
+ If you are experiencing issues with your app authenticating/installing the best way to get help fast is to create a repo with the minimal amount of code to demonstrate the issue and a clearly documented set of steps you took to arrive there. This will help us solve your problem quicker since we won't need to spend any time figuring out how to reproduce the bug. Please also include your operating system and browser.
@@ -21,9 +21,8 @@ The next step is to create a new heroku app. Pull up your heroku dashboard and m
21
21
 
22
22
  cli:
23
23
  ```
24
- heroku new
25
- git remote -v
26
- git remote set-url heroku git@heroku.com:<name>.git
24
+ heroku create name
25
+ heroku git:remote -a name
27
26
  ```
28
27
 
29
28
  now we need to let git know where the remote server is so we'll be able to deploy later
@@ -45,18 +44,18 @@ git remote add heroku git@heroku.com:appinfive.git
45
44
  4. Add ShopifyApp to gemfile
46
45
  ----------------------------
47
46
  ```
48
- vim Gemfile
49
- add
50
- gem 'shopify_app', '~> 6.0.6'
47
+ $ echo "gem 'shopify_app'" >> Gemfile
51
48
 
52
49
  bundle install
53
50
  ```
54
51
 
52
+ 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
+
55
54
  5. Run the ShopifyApp generator
56
55
  -------------------------------
57
56
  ```
58
57
  use the keys from your app in the partners area
59
- rails generate shopify_app -api_key=a366cbafaccebd2f615aebdfc932fa1c -secret=8750306a895b3dbc7f4136c2ae2ea293 -redirect_uri=https://<name>.herokuapp.com/auth/shopify/callback
58
+ rails generate shopify_app --api_key a366cbafaccebd2f615aebdfc932fa1c --secret 8750306a895b3dbc7f4136c2ae2ea293
60
59
  git add .
61
60
  git commit -m 'generated shopify app'
62
61
  ```
data/README.md CHANGED
@@ -6,7 +6,9 @@ Shopify Application Rails engine and generator
6
6
 
7
7
  Description
8
8
  -----------
9
- This gem includes some common code and generators for writing Rails applications using the Shopify API.
9
+ This gem includes a Rails Engine and generators for writing Rails applications using the Shopify API. The Engine provides a SessionsController and all the required code for authenticating with a shop.
10
+
11
+ The [example](https://github.com/Shopify/shopify_app/tree/master/example) directory contains an app that was generated with this gem. It also contains sample code demonstrating the usage of the embedded app sdk.
10
12
 
11
13
  *Note: It's recommended to use this on a new Rails project, so that the generator won't overwrite/delete some of your files.*
12
14
 
@@ -27,7 +29,7 @@ If you don't have a Shopify Partner account yet head over to http://shopify.com/
27
29
  Once you have a Partner account create a new application to get an Api key and other Api credentials. To create a development application set the Application Callback URL to
28
30
 
29
31
  ```
30
- http://localhost:3000/login
32
+ http://localhost:3000/
31
33
  ```
32
34
 
33
35
  and the `redirect_uri` to
@@ -61,6 +63,15 @@ Now we are ready to run any of the shopify_app generators. The following section
61
63
  Generators
62
64
  ----------
63
65
 
66
+ ### Default Generator
67
+
68
+ The default generator will run the `install`, `shop`, and `home_controller` generators. This is the recommended way to start your app.
69
+
70
+ ```sh
71
+ $ rails generate shopify_app --api_key <your_api_key> --secret <your_app_secret>
72
+ ```
73
+
74
+
64
75
  ### Install Generator
65
76
 
66
77
  ```sh
@@ -68,17 +79,16 @@ $ rails generate shopify_app:install
68
79
 
69
80
  # or optionally with arguments:
70
81
 
71
- $ rails generate shopify_app:install -api_key=<your_api_key> -secret=<your_app_secret>
82
+ $ rails generate shopify_app:install --api_key <your_api_key> --secret <your_app_secret>
72
83
  ```
73
84
 
74
85
  Other options include:
75
86
  * `scope` - the Oauth access scope required for your app, eg 'read_products, write_orders'. For more information read the [docs](http://docs.shopify.com/api/tutorials/oauth)
76
- * `embedded` - the default is to generate an [embedded app](http://docs.shopify.com/embedded-app-sdk), if you want a legacy non-embedded app then set this to false, `-embedded false`
77
- * `redirect_uri` - the default is `http://localhost:3000/auth/shopify/callback` which will allow you to develop locally. You'll need to change it to match your domain for production.
87
+ * `embedded` - the default is to generate an [embedded app](http://docs.shopify.com/embedded-app-sdk), if you want a legacy non-embedded app then set this to false, `--embedded false`
78
88
 
79
89
  You can update any of these settings later on easily, the arguments are simply for convenience.
80
90
 
81
- The generator creates a basic SessionsController for authenticating with your shop and a HomeController which displays basic information about your products using the ShopifyAPI. The generated controllers include concerns provided by this gem - in this way code sharing is possible and if some of these core methods are updated everyone can benefit. It is completely safe to override any of the methods provided by this gem in your application.
91
+ The generator adds ShopifyApp and the required initializers to the host Rails application.
82
92
 
83
93
  After running the `install` generator, you can start your app with `bundle exec rails server` and install your app by visiting localhost.
84
94
 
@@ -93,15 +103,19 @@ The install generator doesn't create any database models for you and if you are
93
103
 
94
104
  *Note that you will need to run rake db:migrate after this generator*
95
105
 
96
- ### Controllers, Routes and Views
97
106
 
98
- The last group of generators are for your convenience when you want to start overriding code included as part of the Rails engine. For example by default the engine provides a simple SessionController, if you run the `rails generate shopify_app:controllers` generator then this code gets copied out into your app so you can start adding to it. Routes and views follow the exact same pattern.
107
+ ### Home Controller Generator
99
108
 
109
+ ```sh
110
+ $ rails generate shopify_app:home_controller
111
+ ```
100
112
 
101
- ### Default Generator
113
+ This generator creates an example home controller and view which fetches and displays products using the ShopifyAPI
102
114
 
103
- If you just run `rails generate shopify_app` then all the generators will be run for you. This is how we do it internally!
104
115
 
116
+ ### Controllers, Routes and Views
117
+
118
+ The last group of generators are for your convenience if you want to start overriding code included as part of the Rails engine. For example by default the engine provides a simple SessionController, if you run the `rails generate shopify_app:controllers` generator then this code gets copied out into your app so you can start adding to it. Routes and views follow the exact same pattern.
105
119
 
106
120
 
107
121
  Managing Api Keys
@@ -113,7 +127,6 @@ The `install` generator places your Api credentials directly into the shopify_ap
113
127
  ShopifyApp.configure do |config|
114
128
  config.api_key = ENV['SHOPIFY_CLIENT_API_KEY']
115
129
  config.secret = ENV['SHOPIFY_CLIENT_API_SECRET']
116
- config.redirect_uri = "http://localhost:3000/auth/shopify/callback"
117
130
  config.scope = 'read_customers, read_orders, write_products'
118
131
  config.embedded_app = true
119
132
  end
@@ -128,18 +141,20 @@ ShopifyApp can manage your app's webhooks for you by setting which webhooks you
128
141
  ```ruby
129
142
  ShopifyApp.configure do |config|
130
143
  config.webhooks = [
131
- {topic: 'carts/update', address: 'example-app.com/webhooks'}
144
+ {topic: 'carts/update', address: 'example-app.com/webhooks/carts_update'}
132
145
  ]
133
146
  end
134
147
  ```
135
148
 
136
149
  When the oauth callback is completed successfully ShopifyApp will queue a background job which will ensure all the specified webhooks exist for that shop. Because this runs on every oauth callback it means your app will always have the webhooks it needs even if the user uninstalls and re-installs the app.
137
150
 
138
- There is also a WebhooksController module that you can include in a controller that receives Shopify webhooks. For example:
151
+ ShopifyApp also provides a WebhooksController that receives webhooks and queues a job based on the webhook url. For example if you register the webhook from above then all you need to do is create a job called `CartsUpdateJob`. The job will be queued with 2 params `shop_domain` and `webhook` which is the webhook body.
152
+
153
+ If you'd rather implement your own controller then you'll want to use the WebhookVerfication module to verify your webhooks:
139
154
 
140
155
  ```ruby
141
- class WebhooksController < ApplicationController
142
- include ShopifyApp::WebhooksController
156
+ class CustomWebhooksController < ApplicationController
157
+ include ShopifyApp::WebhookVerification
143
158
 
144
159
  def carts_update
145
160
  SomeJob.perform_later(shopify_domain: shop_domain)
@@ -152,6 +167,13 @@ The module skips the `verify_authenticity_token` before_action and adds an actio
152
167
 
153
168
  The WebhooksManager uses ActiveJob, if ActiveJob is not configured then by default Rails will run the jobs inline. However it is highly recommended to configure a proper background processing queue like sidekiq or resque in production.
154
169
 
170
+ ShopifyApp can create webhooks for you using the `add_webhook` generator. This will add the new webhook to your config and create the required job class for you.
171
+
172
+ ```
173
+ rails g shopify_app:add_webhook -t carts/update -a https://example.com/webhooks/carts_update
174
+ ```
175
+
176
+ where `-t` is the topic and `-a` is the address the webhook should be sent to.
155
177
 
156
178
  ShopifyApp::SessionRepository
157
179
  -----------------------------
@@ -163,7 +185,7 @@ If you only run the install generator then by default you will have an in memory
163
185
  AuthenticatedController
164
186
  -----------------------
165
187
 
166
- The engine includes a controller called `AuthenticatedController` which inherits from `ApplicationController`. 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.
188
+ The engine includes a controller called `ShopifyApp::AuthenticatedController` which inherits from `ApplicationController`. 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.
167
189
 
168
190
  Troubleshooting
169
191
  ---------------
data/Rakefile CHANGED
@@ -1,10 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
- Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
- t.test_files = FileList['test/**/*_test.rb']
7
- t.verbose = true
8
- end
4
+ require File.expand_path('../test/dummy/config/application', __FILE__)
9
5
 
10
- task :default => :test
6
+ Rails.application.load_tasks
@@ -0,0 +1,7 @@
1
+ module ShopifyApp
2
+ class AuthenticatedController < ApplicationController
3
+ before_action :login_again_if_different_shop
4
+ around_filter :shopify_session
5
+ layout ShopifyApp.configuration.embedded_app? ? 'embedded_app' : 'application'
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module ShopifyApp
2
+ class SessionsController < ApplicationController
3
+ include ShopifyApp::SessionsConcern
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ module ShopifyApp
2
+ class WebhooksController < ApplicationController
3
+ include ShopifyApp::WebhookVerification
4
+
5
+ class ShopifyApp::MissingWebhookJobError < StandardError; end
6
+
7
+ def receive
8
+ job_args = {shop_domain: shop_domain, webhook: webhook_params}
9
+ webhook_job_klass.perform_later(job_args)
10
+ head :no_content
11
+ end
12
+
13
+ private
14
+
15
+ def webhook_params
16
+ params.except(:controller, :action, :type)
17
+ end
18
+
19
+ def webhook_job_klass
20
+ "#{webhook_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
21
+ end
22
+
23
+ def webhook_type
24
+ params[:type]
25
+ end
26
+ end
27
+ end
@@ -5,4 +5,8 @@ ShopifyApp::Engine.routes.draw do
5
5
  get 'auth/shopify/callback' => :callback
6
6
  get 'logout' => :destroy, :as => :logout
7
7
  end
8
+
9
+ namespace :webhooks do
10
+ post ':type' => :receive
11
+ end
8
12
  end
@@ -0,0 +1,61 @@
1
+ require 'rails/generators/base'
2
+
3
+ module ShopifyApp
4
+ module Generators
5
+ class AddWebhookGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ class_option :topic, type: :string, aliases: "-t", required: true
9
+ class_option :address, type: :string, aliases: "-a", required: true
10
+
11
+ def init_webhook_config
12
+ initializer = load_initializer
13
+ return if initializer.include?("config.webhooks")
14
+
15
+ inject_into_file(
16
+ 'config/initializers/shopify_app.rb',
17
+ " config.webhooks = [\n ]\n",
18
+ before: 'end'
19
+ )
20
+ end
21
+
22
+ def inject_webhook_to_shopify_app_initializer
23
+ inject_into_file(
24
+ 'config/initializers/shopify_app.rb',
25
+ webhook_config,
26
+ after: "config.webhooks = ["
27
+ )
28
+
29
+ initializer = load_initializer
30
+
31
+ unless initializer.include?(webhook_config)
32
+ shell.say "Error adding webhook to config. Add this line manually: #{webhook_config}", :red
33
+ end
34
+ end
35
+
36
+ def add_webhook_job
37
+ @job_file_name = address.split('/').last + '_job'
38
+ @job_class_name = @job_file_name.classify
39
+ template 'webhook_job.rb', "app/jobs/#{@job_file_name}.rb"
40
+ end
41
+
42
+ private
43
+
44
+ def load_initializer
45
+ File.read(File.join(destination_root, 'config/initializers/shopify_app.rb'))
46
+ end
47
+
48
+ def webhook_config
49
+ "\n {topic: '#{topic}', address: '#{address}', format: 'json'},"
50
+ end
51
+
52
+ def topic
53
+ options['topic']
54
+ end
55
+
56
+ def address
57
+ options['address']
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,8 @@
1
+ class <%= @job_class_name %> < ActiveJob::Base
2
+ def perform(shop_domain:, webhook:)
3
+ shop = Shop.find_by(shopify_domain: shop_domain)
4
+
5
+ shop.with_shopify_session do
6
+ end
7
+ end
8
+ end
@@ -14,7 +14,7 @@ module ShopifyApp
14
14
  private
15
15
 
16
16
  def controllers
17
- files_within_root('.', 'app/controllers/*.*')
17
+ files_within_root('.', 'app/controllers/shopify_app/*.*')
18
18
  end
19
19
 
20
20
  def files_within_root(prefix, glob)
@@ -20,7 +20,6 @@ module ShopifyApp
20
20
  end
21
21
 
22
22
  def add_home_index_route
23
- route "mount ShopifyApp::Engine, at: '/'"
24
23
  route "root :to => 'home#index'"
25
24
  end
26
25
 
@@ -1,4 +1,4 @@
1
- class HomeController < AuthenticatedController
1
+ class HomeController < ShopifyApp::AuthenticatedController
2
2
  def index
3
3
  @products = ShopifyAPI::Product.find(:all, :params => {:limit => 10})
4
4
  end
@@ -6,26 +6,17 @@ module ShopifyApp
6
6
  class InstallGenerator < Rails::Generators::Base
7
7
  include Rails::Generators::Migration
8
8
  source_root File.expand_path('../templates', __FILE__)
9
- attr_reader :opts
10
9
 
11
- def initialize(args, *options)
12
- @opts = Hash[options.first.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/)]
13
- @opts = @opts.with_indifferent_access
14
- @opts.reverse_merge!(defaults)
15
- super(args, *options)
16
- end
17
-
18
- def defaults
19
- {
20
- api_key: '<api_key>',
21
- secret: '<secret>',
22
- redirect_uri: 'http://localhost:3000/auth/shopify/callback',
23
- scope: 'read_orders, read_products',
24
- embedded: 'true'
25
- }
26
- end
10
+ class_option :api_key, type: :string, default: '<api_key>'
11
+ class_option :secret, type: :string, default: '<secret>'
12
+ class_option :scope, type: :string, default: 'read_orders, read_products'
13
+ class_option :embedded, type: :string, default: 'true'
27
14
 
28
15
  def create_shopify_app_initializer
16
+ @api_key = options['api_key']
17
+ @secret = options['secret']
18
+ @scope = options['scope']
19
+
29
20
  template 'shopify_app.rb', 'config/initializers/shopify_app.rb'
30
21
  end
31
22
 
@@ -56,7 +47,7 @@ module ShopifyApp
56
47
  inject_into_class(
57
48
  "app/controllers/application_controller.rb",
58
49
  'ApplicationController',
59
- " include ShopifyApp::Controller\n"
50
+ " include ShopifyApp::LoginProtection\n"
60
51
  )
61
52
  end
62
53
 
@@ -67,11 +58,14 @@ module ShopifyApp
67
58
  end
68
59
  end
69
60
 
61
+ def mount_engine
62
+ route "mount ShopifyApp::Engine, at: '/'"
63
+ end
70
64
 
71
65
  private
72
66
 
73
67
  def embedded_app?
74
- opts[:embedded] != 'false'
68
+ options['embedded'] == 'true'
75
69
  end
76
70
  end
77
71
  end
@@ -18,14 +18,14 @@
18
18
 
19
19
  <%= render 'layouts/flash_messages' %>
20
20
 
21
- <script src="//cdn.shopify.com/s/assets/external/app.js?<%= Time.now.strftime('%Y%m%d%H') %>"></script>
21
+ <script src="https://cdn.shopify.com/s/assets/external/app.js?<%= Time.now.strftime('%Y%m%d%H') %>"></script>
22
22
 
23
23
  <script type="text/javascript">
24
24
  ShopifyApp.init({
25
25
  apiKey: "<%= ShopifyApp.configuration.api_key %>",
26
26
  shopOrigin: "<%= "https://#{ @shop_session.url }" if @shop_session %>",
27
27
  debug: <%= Rails.env.development? ? 'true' : 'false' %>,
28
- forceRedirect: false
28
+ forceRedirect: true
29
29
  });
30
30
  </script>
31
31