Skip to content

Commit 1a46686

Browse files
authored
Merge pull request #254 from mamhoff/flickwerk-patches
Use flickwerk-style patches
2 parents f535321 + e6dface commit 1a46686

File tree

10 files changed

+62
-60
lines changed

10 files changed

+62
-60
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Gemspec/OrderedDependencies:
2121
Layout/ArgumentAlignment:
2222
Exclude:
2323
- 'app/models/spree/user.rb'
24-
- 'lib/spree/authentication_helpers.rb'
2524
- 'spec/controllers/spree/user_sessions_controller_spec.rb'
2625
- 'spec/features/sign_out_spec.rb'
2726

@@ -351,7 +350,6 @@ Style/GuardClause:
351350
- 'db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb'
352351
- 'db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb'
353352
- 'db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb'
354-
- 'lib/spree/authentication_helpers.rb'
355353

356354
# Offense count: 1
357355
# This cop supports safe autocorrection (--autocorrect).
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
module SolidusAuthDevise
4+
module ApplicationControllerPatch
5+
def self.prepended(base)
6+
return unless base.respond_to?(:helper_method)
7+
8+
base.send(:helper_method, :spree_current_user)
9+
10+
return unless SolidusSupport.frontend_available?
11+
12+
base.send(:helper_method, :spree_login_path)
13+
base.send(:helper_method, :spree_signup_path)
14+
base.send(:helper_method, :spree_logout_path)
15+
end
16+
17+
def spree_current_user
18+
current_spree_user
19+
end
20+
21+
if SolidusSupport.frontend_available?
22+
delegate :login_path, :signup_path, :logout_path,
23+
to: :spree,
24+
prefix: :spree
25+
end
26+
27+
ApplicationController.prepend self
28+
end
29+
end

lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb renamed to lib/patches/backend/controllers/solidus_auth_devise/admin/base_controller_patch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

3-
module Spree
3+
module SolidusAuthDevise
44
module Admin
5-
module BaseControllerDecorator
5+
module BaseControllerPatch
66
protected
77

88
def model_class
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
module SolidusAuthDevise
4+
module Admin
5+
module Orders
6+
module CustomerDetailsControllerPatch
7+
def self.prepended(base)
8+
base.before_action :check_authorization
9+
end
10+
11+
private
12+
13+
def check_authorization
14+
load_order
15+
session[:access_token] ||= params[:token]
16+
17+
resource = @order
18+
action = params[:action].to_sym
19+
action = :edit if action == :show # show route renders :edit for this controller
20+
21+
authorize! action, resource, session[:access_token]
22+
end
23+
24+
Spree::Admin::Orders::CustomerDetailsController.prepend self
25+
end
26+
end
27+
end
28+
end

lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb renamed to lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

3-
module Spree
4-
module CheckoutControllerDecorator
3+
module SolidusAuthDevise
4+
module CheckoutControllerPatch
55
def self.prepended(base)
66
base.before_action :check_registration, except: [:registration, :update_registration]
77
base.before_action :check_authorization

lib/solidus_auth_devise.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@
1010
require 'solidus_auth_devise/configuration'
1111
require 'solidus_auth_devise/version'
1212
require 'solidus_auth_devise/engine'
13-
14-
require 'spree/authentication_helpers'

lib/spree/auth/engine.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class Engine < Rails::Engine
2424
config.to_prepare do
2525
Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available?
2626
Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available?
27-
28-
ApplicationController.include Spree::AuthenticationHelpers
2927
end
3028

3129
def self.redirect_back_on_unauthorized?

lib/spree/authentication_helpers.rb

Lines changed: 0 additions & 27 deletions
This file was deleted.

solidus_auth_devise.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
3232
spec.add_dependency 'devise', '~> 4.1'
3333
spec.add_dependency 'devise-encryptable', '0.2.0'
3434
spec.add_dependency 'solidus_core', ['>= 3', '< 5']
35-
spec.add_dependency 'solidus_support', '~> 0.5'
35+
spec.add_dependency 'solidus_support', '~> 0.11'
3636

3737
spec.add_development_dependency 'solidus_backend'
3838
spec.add_development_dependency 'solidus_frontend'

0 commit comments

Comments
 (0)