shopify_app 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,7 @@ class ShopifyAppGenerator < Rails::Generators::Base
13
13
  def copy_files
14
14
  directory 'app'
15
15
  directory 'public'
16
+ directory 'config'
16
17
  end
17
18
 
18
19
  def remove_static_index
@@ -45,6 +46,7 @@ class ShopifyAppGenerator < Rails::Generators::Base
45
46
  route "match 'login' => 'login#index', :as => :login"
46
47
  route "match 'design' => 'home#design'"
47
48
  route "match 'welcome' => 'home#welcome'"
49
+ route "match 'auth/shopify/callback' => 'login#finalize'"
48
50
  end
49
51
  end
50
52
 
@@ -10,23 +10,17 @@ class LoginController < ApplicationController
10
10
 
11
11
  def authenticate
12
12
  if params[:shop].present?
13
- redirect_to ShopifyAPI::Session.new(params[:shop].to_s.strip).create_permission_url
13
+ redirect_to "/auth/shopify?shop=#{params[:shop].to_s.strip}"
14
14
  else
15
15
  redirect_to return_address
16
16
  end
17
17
  end
18
18
 
19
- # Shopify redirects the logged-in user back to this action along with
20
- # the authorization token t.
21
- #
22
- # This token is later combined with the developer's shared secret to form
23
- # the password used to call API methods.
24
19
  def finalize
25
- shopify_session = ShopifyAPI::Session.new(params[:shop], params[:t], params)
26
- if shopify_session.valid?
27
- session[:shopify] = shopify_session
28
- flash[:notice] = "Logged in to shopify store."
29
-
20
+ if response = request.env['omniauth.auth']
21
+ sess = ShopifyAPI::Session.new(params['shop'], response['credentials']['token'])
22
+ session[:shopify] = sess
23
+ flash[:notice] = "Logged in"
30
24
  redirect_to return_address
31
25
  session[:return_to] = nil
32
26
  else
@@ -0,0 +1,12 @@
1
+ Rails.application.config.middleware.use OmniAuth::Builder do
2
+ provider :shopify,
3
+ ShopifyApp.configuration.api_key,
4
+ ShopifyApp.configuration.secret,
5
+ :scope => 'write_script_tags,write_shipping,write_orders,read_orders,read_products,read_customers,read_content',
6
+ :setup => lambda {|env|
7
+ params = Rack::Utils.parse_query(env['QUERY_STRING'])
8
+ site_url = "https://#{params['shop']}"
9
+ Rails.logger.info(env['omniauth.strategy'])
10
+ env['omniauth.strategy'].options[:client_options][:site] = site_url
11
+ }
12
+ end
@@ -1,4 +1,5 @@
1
1
  require 'shopify_api'
2
+ require 'omniauth-shopify-oauth2'
2
3
 
3
4
  module ShopifyApp
4
5
 
@@ -4,9 +4,11 @@ module ShopifyApp::LoginProtection
4
4
  begin
5
5
  # session[:shopify] set in LoginController#finalize
6
6
  ShopifyAPI::Base.site = session[:shopify].site
7
+ ShopifyAPI::Base.activate_session(session[:shopify])
7
8
  yield
8
9
  ensure
9
10
  ShopifyAPI::Base.site = nil
11
+ ShopifyAPI::Base.clear_session
10
12
  end
11
13
  else
12
14
  session[:return_to] = request.fullpath
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = "2.1.2"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = ShopifyApp::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.author = "Shopify"
10
- s.email = ["edward@shopify.com", "willem@shopify.com"]
10
+ s.email = ["edward@shopify.com", "willem@shopify.com", "david.underwood@shopify.com"]
11
11
  s.homepage = "http://www.shopify.com/developers"
12
12
  s.summary = %q{This gem is used to get quickly started with the Shopify API}
13
13
  s.description = %q{Creates a basic login controller for authenticating with your Shop and also a product controller which lets your edit your products easily.}
@@ -15,7 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "shopify-api"
16
16
 
17
17
  s.add_runtime_dependency('rails', '~> 3.1')
18
- s.add_runtime_dependency('shopify_api', '2.3.0')
18
+ s.add_runtime_dependency('shopify_api', '3.0.0')
19
+ s.add_runtime_dependency('omniauth-shopify-oauth2', '1.0.0')
19
20
 
20
21
  s.add_development_dependency('rake')
21
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-05 00:00:00.000000000 Z
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70317972340440 !ruby/object:Gem::Requirement
16
+ requirement: &70366611983880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,32 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70317972340440
24
+ version_requirements: *70366611983880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shopify_api
27
- requirement: &70317972339520 !ruby/object:Gem::Requirement
27
+ requirement: &70366611983380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
31
31
  - !ruby/object:Gem::Version
32
- version: 2.3.0
32
+ version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70317972339520
35
+ version_requirements: *70366611983380
36
+ - !ruby/object:Gem::Dependency
37
+ name: omniauth-shopify-oauth2
38
+ requirement: &70366611982920 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70366611982920
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rake
38
- requirement: &70317972338580 !ruby/object:Gem::Requirement
49
+ requirement: &70366611982540 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,12 +54,13 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *70317972338580
57
+ version_requirements: *70366611982540
47
58
  description: Creates a basic login controller for authenticating with your Shop and
48
59
  also a product controller which lets your edit your products easily.
49
60
  email:
50
61
  - edward@shopify.com
51
62
  - willem@shopify.com
63
+ - david.underwood@shopify.com
52
64
  executables: []
53
65
  extensions: []
54
66
  extra_rdoc_files: []
@@ -83,6 +95,7 @@ files:
83
95
  - lib/generators/shopify_app/templates/app/views/home/welcome.html.erb
84
96
  - lib/generators/shopify_app/templates/app/views/layouts/application.html.erb
85
97
  - lib/generators/shopify_app/templates/app/views/login/index.html.erb
98
+ - lib/generators/shopify_app/templates/config/initializers/omniauth.rb
86
99
  - lib/generators/shopify_app/templates/public/404.html
87
100
  - lib/generators/shopify_app/templates/public/422.html
88
101
  - lib/generators/shopify_app/templates/public/500.html